如何将 JQuery UI 日期选择器绑定到 CKEditor 对话框中的文本字段?
How do I bind a JQuery UI Datepicker to a text field in a CKEditor dialog?
我正在尝试将 JQuery ui 日期选择器绑定到 CKEditor 对话框中的文本字段。我得到的错误是 jQuery(...)datepicker();不是一个对象。哪个对我来说说 JQuery ui 没有被加载...?
目的只是让日期选择器绑定到 txtDlgReportDate。
当 required 但 alert(jQuery.ui) returns 'undefined'.
时,我可以看到正在加载 JQuery
我的代码是...(为 CKEditor 工具栏创建一个按钮)
谢谢
b='reportSend';
CKEDITOR.plugins.add('reportSend',
{
init: function (editor) {
editor.addCommand('sendReportDialog', new CKEDITOR.dialogCommand('sendReportDialog'));
editor.ui.addButton('reportSend',
{
label: 'Send Report',
command: 'sendReportDialog',
icon: this.path + 'Email16.png'
});
CKEDITOR.dialog.add('sendReportDialog', function (editor) {
return {
title: 'Send Report',
minWidth: 400,
minHeight: 200,
contents:
[
{
id: 'general',
label: 'Settings',
elements:
[
{
type: 'text',
id: 'txtDlgReportDate',
label: 'Report Date:',
labelLayout: 'horizontal',
widths: ['100px', '100px'],
onShow: function (data) {
if (typeof (jQuery) === 'undefined') {
CKEDITOR.scriptLoader.load('//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', function () {
jQuery.noConflict();
});
};
if (typeof (jQuery.ui) === 'undefined') {
CKEDITOR.scriptLoader.load('//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js', function () {
jQuery.noConflict();
});
};
jQuery(this).datepicker();
},
commit: function (data) {
data.txtDlgReportDate = this.getValue();
}
},
{
type: 'select',
id: 'reportType',
label: 'Report Type',
items:
[
['<All>', '-1'],
['...Types', '1']
],
commit: function (data) {
data.reportType = this.getValue();
}
}
]
}
],
onOk: function () {
...send code
});
} // End onOk
}; // end Return
}); // end dialog Def
} // end init
}); // End add plugin
而且...问题是 CKEditor 不仅添加了输入标签,而且用 div 和 table 将其包围,因此添加了日期选择器 'inline'到 div... 为了让它以 'click to show' 类型的方式工作,我们需要获取埋在 CK HTML 中的输入标签的 ID 并应用 .datepicker()对其起作用。
一个工作版本(虽然它需要更多的技巧)是......
{
type: 'text',
id: 'txtDlgReportDate',
label: 'Report Date:',
onShow: function (data) {
// Set the width of the outer div (otherwise it's affected by the CK CSS classes and is too wide)
jQuery('#' + this.domId).css('width', 230);
// Get the input element
var theInput = jQuery('#' + this.domId).find('input');
// Apply the datepicker to the input control
jQuery(theInput.selector).datepicker({
showButtonPanel: true
});
},
我正在尝试将 JQuery ui 日期选择器绑定到 CKEditor 对话框中的文本字段。我得到的错误是 jQuery(...)datepicker();不是一个对象。哪个对我来说说 JQuery ui 没有被加载...?
目的只是让日期选择器绑定到 txtDlgReportDate。 当 required 但 alert(jQuery.ui) returns 'undefined'.
时,我可以看到正在加载 JQuery我的代码是...(为 CKEditor 工具栏创建一个按钮)
谢谢
b='reportSend';
CKEDITOR.plugins.add('reportSend',
{
init: function (editor) {
editor.addCommand('sendReportDialog', new CKEDITOR.dialogCommand('sendReportDialog'));
editor.ui.addButton('reportSend',
{
label: 'Send Report',
command: 'sendReportDialog',
icon: this.path + 'Email16.png'
});
CKEDITOR.dialog.add('sendReportDialog', function (editor) {
return {
title: 'Send Report',
minWidth: 400,
minHeight: 200,
contents:
[
{
id: 'general',
label: 'Settings',
elements:
[
{
type: 'text',
id: 'txtDlgReportDate',
label: 'Report Date:',
labelLayout: 'horizontal',
widths: ['100px', '100px'],
onShow: function (data) {
if (typeof (jQuery) === 'undefined') {
CKEDITOR.scriptLoader.load('//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', function () {
jQuery.noConflict();
});
};
if (typeof (jQuery.ui) === 'undefined') {
CKEDITOR.scriptLoader.load('//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js', function () {
jQuery.noConflict();
});
};
jQuery(this).datepicker();
},
commit: function (data) {
data.txtDlgReportDate = this.getValue();
}
},
{
type: 'select',
id: 'reportType',
label: 'Report Type',
items:
[
['<All>', '-1'],
['...Types', '1']
],
commit: function (data) {
data.reportType = this.getValue();
}
}
]
}
],
onOk: function () {
...send code
});
} // End onOk
}; // end Return
}); // end dialog Def
} // end init
}); // End add plugin
而且...问题是 CKEditor 不仅添加了输入标签,而且用 div 和 table 将其包围,因此添加了日期选择器 'inline'到 div... 为了让它以 'click to show' 类型的方式工作,我们需要获取埋在 CK HTML 中的输入标签的 ID 并应用 .datepicker()对其起作用。
一个工作版本(虽然它需要更多的技巧)是......
{
type: 'text',
id: 'txtDlgReportDate',
label: 'Report Date:',
onShow: function (data) {
// Set the width of the outer div (otherwise it's affected by the CK CSS classes and is too wide)
jQuery('#' + this.domId).css('width', 230);
// Get the input element
var theInput = jQuery('#' + this.domId).find('input');
// Apply the datepicker to the input control
jQuery(theInput.selector).datepicker({
showButtonPanel: true
});
},