这是 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/