从 jQuery 对话框处理提交功能(基于这个问题)。使用 codeigniter 和 jquery。
我想将 ajax POST 绑定到 jquery 对话框按钮单击,但不知道该按钮的选择器应该是什么。我尝试使用 .ui-dialog-buttonpane button:first 或 "this" 作为选择器;都没有工作。
HTML 表格
<?php echo form_open('bookmarks/addBookmark'); ?> //form name: create_bookmark
<?php echo form_input('bookn', $bname); ?>
<?php echo form_hidden('booki', $this->uri->segment(4, 0)); ?>
<button class="bb_button">Bookmark</button>
<?php echo form_close(); ?>
jQuery
$(function() {
        $( "#create_bookmark" ).dialog({
            autoOpen: false,
            width: 250,
            height: 250,
            modal: true,
            buttons: {
                "Add location": function() {    
                $('?????').click(function() {  //How do I specify the dialog button?
            $.ajax({
                url: '/bookmarks/addBookmark',
                type: 'POST',
                data:{"bookn": $("input[name='bookn']").val(), "booki": $("[name='booki']").val()},
                success: function (result) {
                    alert("Your bookmark has been added.");
                }                                         
            }); 
                },
                Cancel: function() {$( this ).dialog( "close" );}
            }
        });
    });