我正在尝试编写一个tinymce插件,所以我查看了http://www.tinymce.com/上的教程“创建插件” 。插入和替换内容没有问题,一切正常。
现在我想在更改列表框的值后自动更改文本框的值。例如,更改列表框元素后,应将事件元素的值写入上面的文本框。我怎样才能访问这个元素?
tinymce.PluginManager.add('myexample', function(editor, url) {
// Add a button that opens a window
editor.addButton('myexample',
{
text: 'Example',
onclick: function()
{
// Open window
editor.windowManager.open({
title: 'Example Plugin',
body: [
// Text
{type: 'textbox', name: 'title', label: 'Text', value: 'temp'},
// Listbox
{type: 'listbox', name: 'test', label: 'Ziel',
'values':
[
{text: 'Eins', value: '1'},
{text: 'Zwei', value: '2'}
],
onselect: function(v)
{
console.log(this.value());
// CHANGE THE VALUE OF THE TEXTBOX ...
// ????
}
}
],
onsubmit: function(e)
{
console.log(e.data.title, e.data.test);
}
});
}
});
});
最佳答案
我知道这是一个老问题,但我面临着同样的问题,我发现 this answer在另一个拯救了我的论坛中。
标准的tinymce方法是将弹出窗口保存在变量中:
var win = editor.windowManager.open({ //etc
然后访问元素:
win.find('#text'); // where text is the name specified
我希望这可以帮助其他人在未来。
关于javascript - tinyMCE插件访问元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20733675/