The content in the text box is configured to use nicEdit, not updating to reflect user changes

My apologies for my low level of English

I use to load a page using jQuery, and I use nicEdit on this page, and I send data to another page using jQuery. But it just sends an empty value instead of what the user wrote in the editor (if I define a default value for my text area, it just sends a default value, not text written by the user). What is the problem and what is the solution?

Thanks.


UPDATE After reading this related article , and he comments at the end and reads the other articles I found, should use this way before submitting the form:

nicEditors.findEditor('textarea_id').saveContent(); 

To do this, I use jquery to select any text field and call the .each() jquery function. For example:

 $('textarea').each(function(){ var IDOfThisTextArea = $(this).attr('id'); nicEditors.findEditor(IDOfThisTextArea).saveContent() }); 

This job is great for a text box created in advance. But I have a text box that was dynamically created using jQuery that the findEditor() function above did not find them and did not saveContent() on them.

For this problem do you suggest ??????

Tnx

+7
jquery edit nicedit
source share
2 answers

The main answer for dynamically created elements is to use something like $('selector').on('click', function(...)) or whathaveyou to dynamically bind to the trigger action so that the body of the function .nice-wrapper textarea any relevant .nice-wrapper textarea (via sensitive selectors) as a jquery $textareas object and before sending

  $textareas.each(function(){ nicEditors.findEditor(this.id).saveContent(); }); 

which then allows you to use some convenient methods such as .serializeArray . Obviously, there are many different ways to solve this problem - for example, maybe you want to attach a form to an event, rather than click a button - but I think that many (most?) Smart solutions fall into the same general category .

+1
source share

How to save all instances, for example, before submitting a form

 $('input[type=submit]').bind('click', function () { for(var i=0;i<nicEditors.nicInstances.length;i++){ nicEditors.nicInstances[i].saveContent(); } }); 
+3
source share

All Articles