与tinymce的jquery jtable [英] jquery jtable with tinymce

查看:72
本文介绍了与tinymce的jquery jtable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能为创建/编辑动作添加jquery jtable插件的tinymce编辑器?

Is it possible to add tinymce editor for jquery jtable plugin for Create / Edit action?

我是jTable插件的新手,但我需要一个字段的tinymce编辑器在jquery jtable的创建/编辑动作中,所以我想知道我可以使用jtable吗?

I am new to jTable plugin, but I need tinymce editor for one field in Create / Edit action of jquery jtable, so I wonder can I use jtable?

我知道我可以在创建/编辑表格中将jtable字段设为textarea,所以我想知道我是否可以在某处添加tinymce?

I know that I can make a jtable field to be textarea in Create / Edit form, so I wonder if I can somehow add tinymce there?

1)如果我使用简单的标准代码在主页面中添加tinymce(调用jtable的地方),那么创建/编辑记录就没有任何事情发生(没有讽刺):

1) If I use simple standard code for adding tinymce in main page (where jtable is called), then nothing happends to Create / Edit record (no tinymce):

<script type="text/javascript">
    tinymce.init({
        selector: "textarea"        
    });
</script>

2)我还尝试编辑核心jtable文件,为每个textarea添加tinymce。它向我展示了tinymce编辑器,但问题在于POST。当我发布表单时,它总是给我空值(应该用tinymce编辑的那个)。

2) I also tried to edit core jtable file adding tinymce to each textarea. It shows me tinymce editor, but the problem is with POST. When I post form it always give me empty value (the one that should be edited with tinymce).

这就是我在jtable脚本中直接添加tinymce的方法:

This is how I append tinymce directly in jtable script:

.append('<script>tinymce.init({selector: "textarea"});</script>');

3)最后一想我试过,使用字段的jTable输入选项:

3) And the last think I tried, using jTable input option for field:

article: {
   title: 'Article',                    
   input: function (data) {
        return 'tinymce.init({selector: "textarea"});<textarea></textarea>';
   },

这给我一些语法错误。我有一些语法错误,但我确信我可以使用这样的东西。

This gies me some syntax error. I have some syntax error, but I am sure that I can use something like this.

推荐答案

经过测试,看来< a href =https://stackoverflow.com/questions/2122085/problem-jquery-and-tinymce-textarea-value-doesnt-submit>此解决方案解决了TinyMCE无法保存到textarea的问题(原因 - jtable中的提交事件超载)。此外,此解决方案卸载并重新加载TinyMCE当jTable关闭并重新打开编辑窗格时。

After testing, it appears that this solution fixes the problem with TinyMCE not saving to the textarea (reason - the submit event within jtable is overloaded). Also, this solution unloads and reloads TinyMCE when the jTable closes and reopens an editing pane.

将它们放在一起 - 这对我有用:

Putting them together -- this worked for me:

formCreated: function (event, data) {

    tinymce.init({
        selector: 'textarea',
        setup: function (editor) {
            editor.on('change', function () {
                editor.save();
            });
        }
    });

    for (var editor_id in tinyMCE.editors) {
        tinyMCE.editors[editor_id].getBody().setAttribute('readonly', '1');
        tinymce.EditorManager.execCommand('mceAddControl', true, editor_id);
        tinymce.EditorManager.execCommand('mceAddEditor', true, editor_id);
    }

},
formClosed: function (event, data) {

    for (var editor_id in tinyMCE.editors) {
        tinyMCE.editors[editor_id].getBody().setAttribute('readonly', '1');
        tinymce.EditorManager.execCommand('mceRemoveControl', true, editor_id);
        tinymce.EditorManager.execCommand('mceRemoveEditor', true, editor_id);
    }

}

这篇关于与tinymce的jquery jtable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆