javascript - tinyMCE插件访问元素

标签 javascript plugins tinymce

我正在尝试编写一个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/

相关文章:

javascript - jQuery 鼠标悬停连续幻灯片循环

ruby - 如何调试被静默忽略的插件?

Tinymce 4.x 扩展插件

TFS Sprint 项目打印插件

eclipse - 在 Eclipse 中使用 Angular 插件创建模块

javascript - 用于tinymce的拖放图像和上传插件

javascript - 如何彻底摧毁tinymce?

javascript - 如何更改事件中的 JavaScript 对象值

javascript - ng-repeat 数据仅在文本框焦点更改后更新

javascript - 预期条件失败 : waiting for element to be clickable for element containing style ="display: none;"