javascript - tinymce 插件 - 如何从多个选项卡获取数据?

标签 javascript tinymce-4 tinymce-plugins

这是 JavaScript 代码。我正在使用bodyType: 'tabpanel'因为我想要 2 个标签。麻烦是当 onsubmit: function( e ) { console.log(e.data); }火灾我只得到对象 { nameA: "aaa",ageA: "a1"} 的输出。那么如何从Tab B获取数据呢?

(function() {
     /* Register the buttons */
     tinymce.create('tinymce.plugins.MyButtons', {
          init : function(editor, url) {

               editor.addButton('themedropdownbutton', {
                 title : 'My dropdown button',
                 type: 'menubutton',
                 text: 'Theme Shortcodes',
                 menu: [
                       {
                           text: 'Tabs Example',
                           onclick: function() {
                                var win = editor.windowManager.open( {
                                    title: 'Content Tabs',
                                    bodyType: 'tabpanel',
                                    body: [
                                        {
                                            title: 'My Tab A',
                                            type: "form",
                                            items: [
                                                { name: 'nameA', type: 'textbox', label: 'Your Name TAB A' },
                                                { name: 'ageA', type: 'textbox', label: 'Your Age TAB A' },
                                            ]
                                        },
                                        {
                                            title: 'My Tab B',
                                            type: "form",
                                            items: [
                                                { name: 'nameB', type: 'textbox', label: 'Your Name TAB B' },
                                                { name: 'ageB', type: 'textbox', label: 'Your Age TAB B' },
                                            ]
                                        },
                                    ],
                                    onsubmit: function( e ) {
                                        console.log(e.data);   // output only this - Object { nameA: "aaa", ageA: "a1" }
                                                               // where is { nameB: "bbb", ageB: "b1" }  ?????
                                    }
                                });
                            }
                        },
                        {
                            // other functions
                        },
                     ]  // end menu:
               });
          },
          createControl : function(n, cm) {
               return null;
          },
     });

     tinymce.PluginManager.add( 'my_button_script', tinymce.plugins.MyButtons );

})();

最佳答案

好的,终于找到答案了,如果你有同样的问题,请使用这个

onsubmit: function( e ) {
    var alldata = win.toJSON();
    console.log(JSON.stringify(alldata));  // just for testing, you don't need this line
    // You can then access the results with this example
    editor.insertContent('Tab A name is ' + alldata.nameA + '; Tab B name is ' +  alldata.nameB);
    editor.insertContent('Tab A age is ' + alldata.ageA + '; Tab B age is ' +  alldata.ageB);
}

http://community.tinymce.com/forum/viewtopic.php?id=33852 中找到引用

关于javascript - tinymce 插件 - 如何从多个选项卡获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36789005/

相关文章:

javascript - es6 哈希数组索引函数调用混合语法

javascript - JavaScript 中延迟加载的最佳实践

javascript - D3 x 轴删除垂直条

javascript - 关于焦点,如何将插入符号放在 IE 中已填充字段中的最后一个字符后面?

javascript - TinyMCE 4 初始化按钮

tinymce - 如何使tinyMCE 4.x 中的只读工作?

javascript - 如何在没有额外换行符的情况下在 TinyMCE 中粘贴纯文本?

wordpress - TinyMCE自定义插件,如何根据当前光标位置自动选择单词?

javascript - 如何删除或隐藏 TinyMCE 图像弹出窗口中的图像描述字段