【发布时间】:2014-02-10 19:43:57
【问题描述】:
- 如何在用户单击选项卡时进行 ajax 调用?
- 如何处理 html 响应并将其显示在选项卡中?
- 如何在响应的 html 上绑定 JavaScript 事件?
我知道如何使用 jQueryUI 选项卡以及如何进行 ajax 调用?
当用户单击 CKEditor 中的选项卡时,我不知道如何触发 Ajax 调用?
这是我为在 CKEditor 内的图像对话框上显示“测试”选项卡而编写的。
CKEDITOR.on( 'dialogDefinition', function( ev )
{
// Take the dialog name and its definition from the event
// data.
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
// Check if the definition is from the dialog we're
// interested on (the "Link" dialog).
if ( dialogName == 'image' )
{
// Add a new tab to the "Link" dialog.
dialogDefinition.addContents({
id : 'customTab',
label : 'Test',
accessKey : 'M',
elements : [
{
id : 'myField1',
type : 'text',
label : 'My Text Field'
},
{
id : 'myField2',
type : 'text',
label : 'Another Text Field'
},
{
type : 'html',
html : '<input type="text" name="query" id="query" class="left new-search-box file_dialog_query" style="width:300px !important;" defaulttext="Search Files" value="Search Files">'
},
]
});
}
});
【问题讨论】:
-
你能创建一个jsfiddle吗?
-
阅读基本的ajax tutos怎么样???
-
将点击事件添加到导致ajax请求的选项卡,将来自ajax请求的响应附加到选项卡中,然后附加事件。
-
我猜标签插件会在更改时发出一个事件(例如
change)。监听该事件并启动 ajax 调用。
标签: javascript jquery ajax ckeditor