cakePHP 表单与 YUI 文本编辑器不工作
我正在尝试将 yui 编辑器集成到 cakephp 表单中 编辑器附加到文本区域,我尝试了 handleSubmit
选项,但它不起作用,所以我尝试手动。所以-我已经将一个监听器附加到了onsubmit
,它正在工作......或者没有。
编辑器初始化(来自 yui 站点的复制粘贴,仅名为更改的元素):
(function() {
//Setup some private variables
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
//The SimpleEditor config
var myConfig = {
height: '300px',
width: '99%',
focusAtStart: true
};
//Now let's load the SimpleEditor..
var myEditor = new YAHOO.widget.SimpleEditor('ArticleContent', myConfig);
myEditor.render();
})();
初始化工作正常(我认为),因为编辑器现在保存该记录字段的真实内容。
onsubmit
监听器函数:
function setTextArea()
{
alert('s');
var dd = myEditor.saveHTML();
alert('d');
return false;
}
第一个警报正在工作,因此事件已被处理。 然而,第二个警报从未发生。表单 - 不知何故 - 在它之前提交。 并且,内容不会被保存。
进一步检查显示对 myEditor [甚至警报(myEditor)] 的任何调用都正在提交表单...
有人吗?帮助?我
I am trying to integrate yui editor in a cakephp form
the editor is attached to the textarea, I tried the handleSubmit
option and it didn't work, so I went trying manual. so- I've attached a listener to the onsubmit
, which is working.. or not.
Editor initialization ( a copy-paste from yui site, only element named changed):
(function() {
//Setup some private variables
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
//The SimpleEditor config
var myConfig = {
height: '300px',
width: '99%',
focusAtStart: true
};
//Now let's load the SimpleEditor..
var myEditor = new YAHOO.widget.SimpleEditor('ArticleContent', myConfig);
myEditor.render();
})();
Initialization works fine (I assume) since the editor now holds the real content of that record field.
The onsubmit
listener function:
function setTextArea()
{
alert('s');
var dd = myEditor.saveHTML();
alert('d');
return false;
}
The first alert is working, so the event is handled.
However, the second alert never happens. the form - somehow - is submitted before it.
and, the content is not saved.
further checks shows that ANY call to myEditor [even alert(myEditor)] is submitting the form...
anyone? help? i
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是猜测,但是“saveHTML”函数中的任何代码是否调用了与 cakephp 函数冲突的代码?
如果这是问题,您也许可以通过修改 yui 代码函数名称来解决它(我知道这很老套,但除非有某种方法可以使用自定义命名空间,否则我认为您会被困住)
just a guess, but is any code in the 'saveHTML' function calling something that clashes with cakephp functions?
if this is the problem, you may be able to get around it by modifying the yui code function names (hacky i know, but unless there is some way to use a custom namespace for it i think you'd be stuck with it)
最好的解决方案是使用tinyMCE......
The best solution was to use tinyMCE....