Content in textareas set to use nicEdit not updating to reflect user changes

Accept my apologize because of my low English level

I use to load a page with jQuery and I use nicEdit in that page and I post datas to another page with jQuery. But it just send empty value instead of what user wrote in editor (if i define a default value for my text area, it just send the default value not the text wrote by user). What is the problem and what is the solution?

Thanks.


UPDATE After reading this related article and it's comments at end and reading other articles i found must use this way before submiting form :

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

For this i use jquery to select any textarea and call .each() jquery function. For example :

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

This work fine for textarea that created beforehand. But I have some textarea that created dynamically via jQuery that findEditor() function above didn't found those and not call saveContent() for those.

For this problem what you offer??????

tnx


The basic answer for dynamically created elements is to use something like $('selector').on('click', function(...)) or whathaveyou to dynamically bind to the the triggering action, have that function body find any relevant .nice-wrapper textarea s (via sensible selectors) as a jquery object $textareas , and prior to executing the submit

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

which will then let you use some of the convenience methods like .serializeArray . Obviously, there are many different ways to solve this problem - eg, perhaps you want to bind to the submit event of the form instead of to a click on a button - but I'd think many (most?) of the sensible solutions fall into the same general category.


在提交表单之前,保存所有这样的实例呢?

$('input[type=submit]').bind('click', function () {
    for(var i=0;i<nicEditors.nicInstances.length;i++){
        nicEditors.nicInstances[i].saveContent();
    }
});
链接地址: http://www.djcxy.com/p/48768.html

上一篇: 是nhibernate 3.0准备生产

下一篇: textareas中的内容设置为使用nicEdit不更新以反映用户更改