Answer the question
In order to leave comments, you need to log in
Why does the text editor in the form disappear?
I use wysiwyg editor in my form.
Everything works great.
The site has an "Edit" link, clicking on which sends an ajax request to the edit action of the controller.
The content of the edit.js.erb file is:
$('#place-content').html('<%= escape_javascript( render partial: "form", locals: {place: @place} )%>')
Answer the question
In order to leave comments, you need to log in
There is no problem. It's just that you obviously don't reinitialize the editor after inserting it into the form's DOM.
Most likely, during the first rendering of the page, the following steps take place:
1. The page with the usual form is rendered
2. At the end (or on the document->ready event), the editor is initialized and the form becomes wysiwig
3. Everything happens so quickly that the moment the form transitions to wysiwig you are not watching.
When loading via AJAX, you insert the form, but the code that initializes the editor is nowhere to be found.
Outputs:
1. Cause some event when the DOM changes in the place where you insert the form. And then you can put this code in assets
2. Right in the partial given in the question, add editor initialization
Most of the time, option #2 is preferred.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question