当表单通过javascript提交时,NicEdit不会't保存文本区域

NicEdit doesn't save textarea when form submitted through javascript href

本文关键字:保存 区域 文本 不会 NicEdit 表单 javascript 提交      更新时间:2023-09-26

当javascript提交表单时NicEdit不会保存textareas内容的问题在http://www.netshinesoftware.com/index.php?cID=128&bID=102上进行了讨论,但是

的解决方案

for(var i=0;i<editor1.nicInstances.length;i++){editor1.nicInstances[i].saveContent();}

editor1.addEvent('blur', function() { this.nicInstances[0].saveContent(); });

在使用this创建编辑器时不起作用:

bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });

知道为什么吗?

我也遇到过同样的问题,但是这个方法对我有效。

function submitForm()
{
    var data = new Object();
    var nicE = new nicEditors.findEditor('text');
    var html = nicE.getContent().replace(/'"/ig,'&quot;');
    data["projectid"] = $('select#projects option:selected').val();
    data["type"] = $('select#type option:selected').val();
    data["taskid"] = $('select#taskid option:selected').val();
    data["tasktype"] = $('select#tasktype option:selected').val();
    data["title"] = $('input#title').val().replace(/'"/ig,'&quot;');
    data["text"] = html; 
    xajax_task_action('save_importtask',data);
}

如果您有多个nicEdit实例,请使用迭代并将内容保存在数组中。我希望它能帮助你找到解决问题的办法。