[ACCEPTED]-assign id to jquery dialog button-dialog

Accepted answer
Score: 71

The following (seemingly undocumented) works 2 for me with jQuery 1.8.9:

$("#dlg").dialog({
  buttons :  { 
     "MyButton" : {
         text: "My Button",
         id: "my-button-id",
         click: function(){
             alert("here");
         }   
      } 
   }
});

The button can 1 be addressed via $("#my-button-id")

Score: 20

This code from official site worked for me:

$('#dialog').dialog({
    // properties ... 
    buttons: [{
        id:"btn-accept",
        text: "Accept",
        click: function() {
            $(this).dialog("close");
        }
    }, 
    {
        id:"btn-cancel",
        text: "Cancel",
        click: function() {
            $(this).dialog("close");
        }
    }]
});

0

Score: 3

Try this.

buttons: {
    'MyButton': function() {
        //... configure the button's function
    }

And the id setter

$('button:contains(MyButton)').attr("id","xyz");  

0

Score: 3

@BerndB: Thanks it works perfectly and even 1 is more extendable.

$('#loginlink').live('click',function(){
    DC = 'login_box';
    diaOpt = {
        autoOpen : true,
        width : 400,
        title : 'Login',
        buttons: {
            //valiudate login
            'Login' : {
                text : 'Login Now',
                id : 'validateForm',
                click : function(){
                }   
            }
        }
    }

    launchDialog(diaOpt, DC);
});

$('#validateForm').live('click', function(){
    alert('Hellop');
    $("#loginform").validate();
});
Score: 0
$("#OK",{id:'xyz'});

hope that it helps

0

More Related questions