用 AJAX 加载的 CKEditor + Yii:$_POST 不包含更新的值
简而言之:
我正在使用 Yii 框架
i'm using Yii Framework
我的页面上有一个 Ckeditor 窗口(php/yii 框架 - 工作正常)
i have a one Ckeditor window on my page ( php/ yii framework - works fine)
当我点击一个按钮时,一个新的 CKeditor 窗口正在生成并通过 AJAX 调用显示
when i hit a button, a new CKeditor window is being generated and shown through AJAX call
问题:这个新的 CKEditor 窗口正确显示了存储在数据库中的文本但是:当我点击保存"(与表单的其余部分一起生成的 ajax 按钮)时,这个新的 CKEditor 窗口中的值将不保存:CKeditor 发回它从数据库中获得的旧值.
THE PROBLEM: this new CKEditor window correctly displays the text stored in the database BUT : when i hit "Save" (an ajax button generated together with the rest of the form) the values from this new CKeditor window will not save : CKeditor sends back the old values that it got from the database.
当我移除 Ckeditor 并保留普通的 时:一切正常,所以我知道控制器很好.
When i remove the Ckeditor and leave the plain <textarea>
: everything is ok so i know that the controller is fine.
请问,有人经历过这样的事情吗?
Please, anybody went through something like this?
推荐答案
听起来像是典型的 AJAX 后 JS 绑定问题.:) 解决方法有几种可能,具体取决于发生了什么问题.
Sounds like a typical post-AJAX JS binding issue. :) There are a few possibilities for how to fix it, depending on what is going wrong.
Yii 论坛上的这篇帖子对你来说应该是钱,这是我得到大部分建议的地方:http://www.yiiframework.com/forum/index.php?/topic/9341-ckeditor-widget-in-a-cactiveform/
This post in the Yii forum should be money for you, it's where I got most of these suggestions: http://www.yiiframework.com/forum/index.php?/topic/9341-ckeditor-widget-in-a-cactiveform/
- 使用已经解决了这个问题的小部件 Yii 扩展(NHCKEditor?)
- 向提交按钮添加 onClick 回调,该回调将 CKEditor 内容保存到隐藏的
'textarea' ('onclick'=>'CKEDITOR.instances.TEXTAREA_ID.updateElement()',
莉> - 使用jQuery从CKEditor iFrame中获取数据 在任何地方使用....AJAX 验证等
- Use a widgetized Yii extension which has already solved this problem (NHCKEditor?)
- Add an onClick callback to the submit button which saves the CKEditor content to the hidden
'textarea' ('onclick'=>'CKEDITOR.instances.TEXTAREA_ID.updateElement()',
- Use jQuery to get the data from the CKEditor iFrame to use... wherever. AJAX validation, etc.
祝你好运!
相关文章