XF 2.0 Question about a script for xenforo 2

SyTry

Well-known member
Hello,

I have a script made for XenForo 1.5 and I want to convert it to XenForo 2.0. There are 3 lines blocking me :
Code:
$('iframe.redactor_textCtrl').contents().find('body').html(txt);
$('iframe.redactor_textCtrl').contents().find('body').select();
$('iframe.redactor_textCtrl').contents().find('body').focus();

iframe.redactor_textCtrl is for XenForo 1.5 :
Screenshot_1.webp

I don't know the equivalent for XenForo 2, I tried a lot of different code : div.fr-wrapper, div.fr-wrapper.show-placeholder, ect.
Screenshot_2.webp

If anyone can help me thank you in advance!

Regards, SyTry
 
In XF1 there's an iframe for the editor, in XF2 there's just a div. So you won't find a body Element in XF2 inside the editor. ;)
 
Use froalas events.focus and html.insert methods.
Thank you, I have replaced this :
Code:
$('iframe.redactor_textCtrl').contents().find('body').html(txt);
$('iframe.redactor_textCtrl').contents().find('body').select();
$('iframe.redactor_textCtrl').contents().find('body').focus();

By this :
Code:
$('.selector').froalaEditor('events.focus');
$('.selector').froalaEditor('html.insert');

But my script doesn't work

In XF1 there's an iframe for the editor, in XF2 there's just a div. So you won't find a body Element in XF2 inside the editor. ;)
Thanks but how can I insert my script in the body for XF2 ? The script contains predefined content for topics ^^

SyTry,
 
You don't know much about jQuery, right?

.selector is just a placeholder.

Try to use a real one, like .message-editorWrapper:

e.g.
JavaScript:
$('.message-editorWrapper').froalaEditor('html.insert', 'this is my text', true);
(untested!)

Edit: This one works:
JavaScript:
$('.fr-view').html('this is my text');
The froalaEditor() Methods would be nicer, but my example above does not work.

Not too experienced in JS too..
 
Last edited:
You don't know much about jQuery, right?

.selector is just a placeholder.

Try to use a real one, like .message-editorWrapper:

e.g.
JavaScript:
$('.message-editorWrapper').froalaEditor('html.insert', 'this is my text', true);
(untested!)

Edit: This one works:
JavaScript:
$('.fr-view').html('this is my text');
The froalaEditor() Methods would be nicer, but my example above does not work.

Not too experienced in JS too..
Thank you for your help, I managed to do what I wanted ! :)
 
Top Bottom