Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set jQuery UI dialog button id?

Tags:

Is it possible to set the ID for the buttons in a jQuery UI dialog, so that I can refer to them later through jQuery? For example, trigger events, disable etc?

... in the dialog setup ... buttons: {                    "Sök": function () {         var bValid = true;     },     "OK": function () {         if (OK()) {             getStuffNoteringar($("#txtStuffId").val());             $(this).dialog("close");         }     }  .... later on in some javascript code....  $('#OK').click();  
like image 814
kaze Avatar asked Apr 25 '12 09:04

kaze


2 Answers

$("#myDialog").dialog({   buttons :  {       "MyButton" : {          text: "OK",          id: "okbtnid",          click: function(){              var bValid = true;          }          }     } }); 
like image 134
mprabhat Avatar answered Nov 12 '22 17:11

mprabhat


Or you can do it as an array:

$("#myDialog").dialog({    buttons :  [{       text: "OK",      id: "ok",      click: function(){          alert("clicked");      }       }] }); 

http://docs.jquery.com/UI/Dialog

like image 29
paulslater19 Avatar answered Nov 12 '22 18:11

paulslater19