本文介绍了Ajax提交nicEdit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的一个项目上使用nicEditor,我想使用来自插件的jQuery提交内容.这是我的代码
I'm using nicEditor on one of my projects and i want to submit the content using jQuery from plugin. Here is my code
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor().panelInstance('txt1');
});
</script>
<script>
$(document).ready(function()
{
$('#submit-from').on('submit', function(e)
{
e.preventDefault();
$('#submit').attr('disabled', ''); // disable upload button
//show uploading message
$(this).ajaxSubmit({
target: '#output-login',
success: afterSuccess //call function after success
});
});
});
function afterSuccess()
{
$('#submit-from').resetForm(); // reset form
$('#submit').removeAttr('disabled'); //enable submit button
$('#loadding').html('');
}
</script>
<form id="submit-from" action="submit.php" method="post">
<input type="text" id="title" name="title" />
<textarea id="txt1" name="txt1" ></textarea>
<input type="submit" id="submit" value="Submit"/></div>
</form>
我正在使用
jQuery: http://malsup.com/jquery/form/
nicEdit: http://nicedit.com/
一切正常,除了nicEdit中的内容似乎没有发布.如果我删除了nicEdit文本区域,将发布正确.有人可以指出我的问题吗?非常适合您的帮助.
All work fine except what ever in the nicEdit doesn't seems to be posting. If i remove the nicEdit text area will post fine. Can someone point me out the problem. Really appropriate your help.
推荐答案
尝试一下:
// Get values from NICEditors
$('textarea').each(function () {
var id_nic = $(this).attr('id');
var nic = nicEditors.findEditor(id_nic);
if (nic) nic.saveContent();
});
这篇关于Ajax提交nicEdit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!