2

我正在使用在thickbox 中打开的tinymce 按钮向wordpress 主题添加简码。

我尝试将脚本排入队列以在厚框页面中添加一些动画和验证,但它不起作用。该脚本已正确排队,如果我使用警报功能进行测试,它运行良好,但是当我尝试选择厚盒元素中的任何元素时,它不起作用。

这是创建打开thickbox的tinymce按钮的代码

ed.addButton('twospermsShortcodes_button', {
            title : 'Insert Shortcodes',
            image : url+'/images/star.png',
            onclick : function() {
                tb_show("Insert Shortcode", url + "/popup.php?width=" + 650);
            }

});

这是厚盒页面的代码:

<div id="button-dialog">
<form action="" method="post">
    <div>
        <label for="button-url">Button URL</label>
        <input type="text" name="button-url" value="" id="button-url" />
    </div>
    <div>
        <label for="button-text">Button Text</label>
        <input type="text" name="button-text" value="" id="button-text" />
    </div>
    <div>
        <label for="button-size">Size</label>
        <select name="button-size" id="button-size" size="1">
            <option value="small">Small</option>
            <option value="medium" selected="selected">Medium</option>
            <option value="large">Large</option>
        </select>
    </div>
    <div>
        <label for="button-style">Style</label>
        <select name="button-style" id="button-style" size="1">
            <option value="less_round">Less Round</option>
            <option value="round" selected="selected">Round</option>
            <option value="square">Square</option>
        </select>
    </div>
    <div>
        <label for="button-color">Color</label>
        <select name="button-color" id="button-color" size="1">
            <option value="gray" selected="selected">Gray</option>
            <option value="blue"=>Blue</option>
            <option value="red">Red</option>
            <option value="green">Green</option>
            <option value="black">Black</option>
        </select>
    </div>
    <div>
        <label for="button-align">Alignment</label>
        <select name="button-align" id="button-align" size="1">
            <option value="gray" selected="selected">None</option>
            <option value="left"=>Left</option>
            <option value="right">Right</option>
        </select>
    </div>
    <div>   
        <a href="#" id="insert">Insert</a>
    </div>
</form>
</div>

这是用于将我想添加一些动画的脚本排入队列的代码:

wp_register_script("admin_script2"
    ,get_template_directory_uri() . "/functions/js/shortcodes_handling.js", array('jquery'));
wp_enqueue_script("admin_script2");

这是javascript代码:

jQuery(window).load(function() {

  alert("test");

  jQuery("div#button-dialog a#insert").click(function(e) {
    e.preventDefault();
    alert('fs');
  });

});
4

0 回答 0