2
我需要返回我在jQuery UI对话框中选择的som值。如何在jQuery UI对话框中返回值?
目前我只是设定值是这样的:
jQuery('#fileBrowser input.addImage').live("click", function() {
// 'file' is set when selected in file browser
imageUrlInputBox.val(file); // Add relative image url to text field
jQuery("#fileBrowser").dialog("close");
});
然而现在我所面临的问题是,我打开对话框通过量在TinyMCE的自定义按钮。所以我需要另一种插入图像的方式。这是我想出了:
// This is the function valled when clicking the tinyMCE button
function openImageManager(ed) {
//tinymce is a global variable.
tinymce = ed;
jQuery("#fileBrowser").dialog("open");
}
功能接收来自在TinyMCE插件通过“编”变量。下面是该脚本:
(function() {
tinymce.create('tinymce.plugins.wp_filebrowser_plugin', {
init : function(ed, url){
ed.addButton('wp_filebrowser_plugin', {
title : 'Insert image',
onclick : function() {
openImageManager(ed)
},
image: url + "/img/wand.png"
});
},
getInfo : function() {
return {
longname : 'WP Filebrowser TinyMCE plugin',
};
}
});
tinymce.PluginManager.add('wp_filebrowser_plugin', tinymce.plugins.wp_filebrowser_plugin);
})();
现在,点击插入按钮时,我可以执行以下代码将数据插入文本编辑器:
jQuery('#fileBrowser input.addImage').live("click", function() {
var img_html = '<img class="' + css_class + '" src="' + file_url + '" title="' + alt + '" alt="" />';
tinymce.execCommand('mceInsertContent', false, img_html);
});
SOLUTION
感谢对TJ克劳德,我找到了答案。代码已更新以反映此情况。
啊,谢谢你的评论。它帮助我找到解决方案。查看我更新的代码。 – Steven 2010-11-28 14:10:30