cakePHP 表单与 YUI 文本编辑器不工作

发布于 2024-10-22 23:07:28 字数 991 浏览 8 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沦落红尘 2024-10-29 23:07:28

只是猜测,但是“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)

叹沉浮 2024-10-29 23:07:28

最好的解决方案是使用tinyMCE......

The best solution was to use tinyMCE....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文