Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

assign id to jquery dialog button

How do i assign an an id to a jquery dialog button. I tried the following but it's not working

buttons: { Ok: function() { id="xyz", ... 
like image 370
Hussein Avatar asked Feb 08 '11 03:02

Hussein


2 Answers

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");         }     }] }); 
like image 23
Andrei Avatar answered Sep 29 '22 11:09

Andrei


The following (seemingly undocumented) works 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 be addressed via $("#my-button-id")

like image 104
BerndB Avatar answered Sep 29 '22 10:09

BerndB