EasyUI Forum
May 03, 2024, 01:08:16 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: texteditor insertContent  (Read 4492 times)
proceno72
Newbie
*
Posts: 39



View Profile
« 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?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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.
Logged
proceno72
Newbie
*
Posts: 39



View Profile
« Reply #2 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
« Last Edit: April 19, 2019, 04:28:14 AM by proceno72 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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>');
Logged
proceno72
Newbie
*
Posts: 39



View Profile
« Reply #4 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!