M
M
michaelromanov902016-12-05 21:40:57
Yii
michaelromanov90, 2016-12-05 21:40:57

How to restore focus in summernote?

Good afternoon. I've been struggling with the task for an hour ... I can't do it .. The summernote.org library / plugin works
for me (yii2)

print $form->field($model, 'body_full')->textarea(['id'=>'editor']);

tried the experiment for the sake of
<textarea id="editor"></textarea>
All methods that do not affect the position of the cursor work well. But as soon as I try to insert text (for example) at the cursor position, the insertion always occurs at the beginning of the line.
At the same time, which is typical, the same example with a clean form (in a separate file without yii2 (but with links to the same js files)) works as it should (for example , https://jsfiddle.net/wzhwy1uy/)
Please tell me, what's the matter?
those. I have in the form and
<span id="insert">insert</span>
$('#insert').click(function (){
    $('#editor').summernote('insertText', 'Hello, world');
});

and the text Hello, world is inserted only at the beginning of the line. Cursor position is not saved...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
michaelromanov90, 2016-12-05
@michaelromanov90

It's just a tin, some!!!
Replaced span with button (the node that triggers the event) and it worked.
Might be useful to someone in the future.
Although why it is so .... it is not clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question