获取打开对话框的按钮的ID

时间:2015-09-15 16:18:55

标签: jquery jquery-dialog

我在循环内生成的表的每一行内都有一个按钮。该按钮具有类click_link。每行的id都不同。单击该按钮,将创建一个jquery对话框。我需要对话框按钮click()内的按钮ID,即单击“编辑”按钮的事件

$("#dialog_loader").dialog({resizable: false,
  height:"auto",
  modal: true,
  minWidth: 500,
  autoOpen:false,
  buttons: {
    "Edit": function() {
      $.ajax({
            url:url1,
            type:'POST',
            data:data1,
            success:function(msg){
               if(msg)
               {
                  //alert(msg);
                 //Here I need to get the id of the button which creates 
               the dialog.That is id of the button with class **click_link**
               } 
            }
        });
    },
    Cancel: function() {
      $( this ).dialog( "close" );
    }
  }
});

//click event of button
$(document).on('click','.click_link',function(){
    $("#dialog_loader").css({'display':'show'});
    $('#dialog_loader').dialog('open');
});

1 个答案:

答案 0 :(得分:0)

data()属性设置为对话框的ID

$('#dialog_loader').data('dialog_opener',"id of the button which create dialog").dialog('open');

然后打电话给       $("#dialog_loader").data("id of the button which create dialog") 需要的地方