gpt4 book ai didi

javascript - CKEditor如何获取对话框输入

转载 作者:行者123 更新时间:2023-11-30 00:09:51 25 4
gpt4 key购买 nike

我有 CKEditor,我在自己的 plugin.js 文件夹中添加了一个带有 2 个文本区域的对话框,但是当在对话框中按下确定按钮时我无法进行文本输入。

CKEDITOR.dialog.add('ticketDialog', function (editor) {
return {
title: 'Ticket Properties',
minWidth: 100,
minHeight: 100,
maxWidth: 100,
maxHeight: 100,
contents:
[
{
id: 'general',
label: 'Ticket from',
elements:
[
{
type: 'text',
id: 'Ticket',
label: "Write the company's name that you bought from",
'default': "Thy,Pegasus etc."
},
{
type: 'text',
id: 'Price',
label: "Price for single ticket",
'default': "0.00TL"
}
]
}
]

};
});

我有 mvc View 页面,我使用 javascript 将我的 textarea 替换为 CKeditor,我需要在这里处理对话框的 ok 事件。

<script type="text/javascript">
var editor = CKEDITOR.instances['editor1'];
if (editor) { editor.destroy(true); }
CKEDITOR.replace('editor1', {
enterMode: CKEDITOR.ENTER_BR,
extraPlugins: 'ticket',
toolbar: 'Full',
language:'English'
});


CKEDITOR.on('dialogDefinition', function (e) {
var dialogName = e.data.name;
var dialog = e.data.definition.dialog;
dialog.on('ok', function () {
var elementPrice = e.data.definition.dialog.getElement('Price');
var rawValue = elementPrice.getInputElement().$.value; // here I am trying to take the value of Price area input.
alert(rawValue);
//CKEDITOR.instances['editor1'].insertHtml(rawValue);

});
});
</script>

谢谢。

最佳答案

这里是给其他人看好的答案。

CKEDITOR.on('dialogDefinition', function (e) {
var dialogName = e.data.name;
var dialog = e.data.definition.dialog;
dialog.on('ok', function () {
var elementPrice = dialog.getContentElement('general','Price');
});
});

关于javascript - CKEditor如何获取对话框输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36955414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com