gpt4 book ai didi

jquery - WYMeditor 在空时插入

转载 作者:行者123 更新时间:2023-12-01 08:13:08 26 4
gpt4 key购买 nike

我在这个项目中使用 WYMeditor。但是,我有服务器端验证,可以在保存数据之前检查文本区域框是否为空。但是当使用 WYMeditor 时,它会插入 <br />标签,尽管我什至没有在编辑器中单击。

我搜索了一下这个问题,发现它被标记为一个错误,here 。但据说已经修好了。然而,即使我已经下载并正在使用最新的稳定版本,它肯定仍然影响着我。

这是我插入文本区域的代码(我使用的是 CakePHP):

echo $this->Form->create('News', array('type' => 'file'));
echo $this->Form->input('News.title', array('label' => '*Title:'));
echo $this->Form->input('News.body', array('label' => '*Body:', 'class' => 'wymeditor'));
echo $this->Form->input('News.picture', array('label' => 'Picture:', 'type' => 'file'));
echo $this->Form->end(array('label' => 'Save News', 'class' => 'wymupdate'));

还有我的文本区域 JavaScript:

jQuery('.wymeditor').wymeditor({
skin: 'silver',
toolsItems: [
{'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'},
{'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'},
{'name': 'CreateLink', 'title': 'Link', 'css': 'wym_tools_link'},
{'name': 'Unlink', 'title': 'Unlink', 'css': 'wym_tools_unlink'},
{'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list'},
{'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'},
{'name': 'InsertTable', 'title': 'Table', 'css': 'wym_tools_table'},
{'name': 'Undo', 'title': 'Undo', 'css': 'wym_tools_undo'},
{'name': 'Redo', 'title': 'Redo', 'css': 'wym_tools_redo'}
]
});

我没有使用 wymeditor javascript,而是使用所有其他 javascript 对此进行了测试,并且它按预期运行,因此我怀疑 wymeditor javascript 出了问题,但我不确定是什么。

最佳答案

我可以想到导致这些症状的几个可能原因:

  1. 您可能使用的是存在此错误的旧版本 WYMeditor。您使用哪个版本?截至撰写本文时,当前版本为 1.0.0b3 。可以对照WYMeditor大师测试here .

  2. 如果您在不使用表单的提交处理程序的情况下提交表单,则 wymupdate类将无法工作,并且您将无法获得隐式 wym.xhtml()调用,这意味着可能不会发生一些必要的 HTML 清理。您可以尝试调用xhtml()在您的 WYMeditor 实例上(如果您只有一个 wymeditor,则可以使用 jQuery.wymeditors(0) 检索它)。

如果您可以提供示例页面或更多信息,我将相应地更新此答案。

关于jquery - WYMeditor 在空时插入 <br/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12254808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com