jQuery UIダイアログボックスで選択した値を返す必要があります。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の中にカスタムボタンthrougダイアログボックスを開くことです。だから私はイメージを挿入する別の方法が必要でした。これは私が思いついたものです:
// 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プラグインから渡された 'ed'変数を受け取ります。ここではそのためのスクリプトは次のとおりです。
(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 Crowder、私は答えを見つけました。これを反映するようにコードが更新されます。
ご意見ありがとうございます。それは私が解決策を見つけるのを助けた。私の更新されたコードを見てください。 – Steven
@スティーブン:優秀、喜んで助けました。 –