我正在我的一个项目中使用nicEditor,我想使用插件中的jQuery提交内容。以下是我的代码
<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文本区,则可以正常开机自检。有人能给我指出问题所在吗?真的很适合你的帮助。
发布于 2014-06-27 19:46:59
试试这个:
// Get values from NICEditors
$('textarea').each(function () {
var id_nic = $(this).attr('id');
var nic = nicEditors.findEditor(id_nic);
if (nic) nic.saveContent();
}); 发布于 2014-03-13 15:37:34
我认为您应该对nicEdit的可内容编辑div的HTML进行编码,然后在尝试提交表单时将该值传递给文本区域。
$(document).ready(function()
{
$('#submit-from').on('submit', function(e)
{
e.preventDefault();
$('#submit').attr('disabled', ''); // disable upload button
//show uploading message
var encodedHTML = String($('.nicEdit-main').html())
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '<')
.replace(/>/g, '>');
$('#txt1').val(encodedHTML);
$(this).ajaxSubmit({
target: '#output-login',
success: afterSuccess //call function after success
});
});
});https://stackoverflow.com/questions/22370993
复制相似问题