jQuery 对话框中的 CKEditor,如何构建它?
因此,我正在使用 CKEditor 和 jQuery,尝试构建一个弹出编辑器。 下面是我到目前为止编写的代码,但我似乎无法让它按照我想要的方式工作。 基本上,单击“编辑”链接,会弹出对话框,将要编辑的内容加载到 CKEditor 中。
另外,这不是必需的,但如果您能建议如何操作,则会很有帮助。我似乎无法找到如何使保存按钮在 CKEditor 中工作(尽管我认为表单可以做到这一点)。
预先感谢您的任何帮助。
$(document).ready(function(){
var config = new Array();
config.height = "350px";
config.resize_enabled = false;
config.tabSpaces = 4;
config.toolbarCanCollapse = false;
config.width = "700px";
config.toolbar_Full = [["Save","-","Cut","Copy","Paste","-","Undo","Redo","-","Bold","Italic", "-", "NumberedList","BulletedList","-","Link","Unlink","-","Image","Table"]];
$("a.opener").click(function(){
var editid = $(this).attr("href");
var editwin = \'<form><div id="header"><input type="text"></div><div id="content"><textarea id="content"></textarea></div></form>\';
var $dialog = $("<div>"+editwin+"</div>").dialog({
autoOpen: false,
title: "Editor",
height: 360,
width: 710,
buttons: {
"Ok": function(){
var data = $(this).val();
}
}
});
//$(this).dialog("close");
$.getJSON("ajax/" + editid, function(data){
alert("datagrab");
$dialog.("textarea#content").html(data.content).ckeditor(config);
alert("winset");
$dialog.dialog("open");
});
return false;
});
});
So, I'm working with CKEditor and jQuery, trying to build a pop-out editor.
Below is what I have coded so far, and I can't seem to get it working the way I want it to.
Basically, click the 'Edit' link, dialog box pops up, with the content to edit loaded into the CKEditor.
Also, not required, but helpful if you can suggest how to do it. I can't seem to find out how to make the save button work in CKEditor (though I think the form will do it).
Thanks in advance for any help.
$(document).ready(function(){
var config = new Array();
config.height = "350px";
config.resize_enabled = false;
config.tabSpaces = 4;
config.toolbarCanCollapse = false;
config.width = "700px";
config.toolbar_Full = [["Save","-","Cut","Copy","Paste","-","Undo","Redo","-","Bold","Italic", "-", "NumberedList","BulletedList","-","Link","Unlink","-","Image","Table"]];
$("a.opener").click(function(){
var editid = $(this).attr("href");
var editwin = \'<form><div id="header"><input type="text"></div><div id="content"><textarea id="content"></textarea></div></form>\';
var $dialog = $("<div>"+editwin+"</div>").dialog({
autoOpen: false,
title: "Editor",
height: 360,
width: 710,
buttons: {
"Ok": function(){
var data = $(this).val();
}
}
});
//$(this).dialog("close");
$.getJSON("ajax/" + editid, function(data){
alert("datagrab");
$dialog.("textarea#content").html(data.content).ckeditor(config);
alert("winset");
$dialog.dialog("open");
});
return false;
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过更多的挖掘和研究,我已经为我的问题找到了一个有效的解决方案。我在这里发帖以防其他人需要做这样的事情:
After doing some more digging and research, I have hacked together a working solution to my problem. I'm posting here in case anyone else needs to do something like this: