EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: proceno72 on April 18, 2019, 03:45:25 AM



Title: texteditor insertContent
Post by: proceno72 on April 18, 2019, 03:45:25 AM
Anyone hav problem using insertContent method on texteditor extension?
I thought it was a stupid thing: $('#myid').texteditor('insertContent',myTxtStr)
but nothing appears.
Instead $('#myid').texteditor('setValue',myTxtStr) it's fully working.
Why?


Title: Re: texteditor insertContent
Post by: stworthy on April 18, 2019, 08:09:21 PM
The 'insertContent' method insert the content to the current position of the editor. So the editor must get focus before calling this method.


Title: Re: texteditor insertContent
Post by: proceno72 on April 19, 2019, 03:56:30 AM
The 'insertContent' method insert the content to the current position of the editor. So the editor must get focus before calling this method.
I supposed that and tried this immediately after texteditor has been inizialized:
Code:
$('#myid').texteditor('getEditor').focus().select();
$('#myid').texteditor('insertContent',myTxtStr);
but nothing.
I've to manually click with mouse on any position of texteditor and only after that 'insertContent' it'is ok


Title: Re: texteditor insertContent
Post by: stworthy on April 19, 2019, 06:59:50 PM
Try this code instead.
Code:
$('#myid').texteditor('getEditor').focus();
$('#myid').texteditor('getEditor').trigger('mouseup');
$('#myid').texteditor('insertContent', '<p>new content</p>');


Title: Re: texteditor insertContent
Post by: proceno72 on April 22, 2019, 02:11:04 AM
Try this code instead.
Code:
$('#myid').texteditor('getEditor').focus();
$('#myid').texteditor('getEditor').trigger('mouseup');
$('#myid').texteditor('insertContent', '<p>new content</p>');
Thanks. This works.