Reputation: 301
I am using Jquery's dialog() method to create dialog. I am creating buttons on the dialog while creating the dialog, using
$("#divName").dialog({
buttons:
{
"Cancel":{
I have one event on which I need to hide the button,but don't know which attributes to use. Please tell me the attributes to hide button. Thanks in advance.
Upvotes: 17
Views: 21927
Reputation: 1
Try this jQuery selector to hide the "cancel" button. Adjust childNodes
index according to your buttons order.
$('.ui-dialog-buttonset')[0].childNodes[0].hide();
Upvotes: 0
Reputation: 161
If you're trying to hide the "cancel" button, try this.
$('.ui-dialog-buttonpane button:contains("cancel")').button().hide();
Upvotes: 16
Reputation: 153
When you create the dialog, you describe the buttons and the attributes of the buttons, so add an "id" attribute to the button:
buttons: [ { text: "Save", id: "btnId", click: function() { ... } } ]
You can then use the id as a jquery filter for the hide() and show() methods:
$("#btnId").hide()...
Upvotes: 7
Reputation: 5817
This will hide first button:
$('#divName').siblings('.ui-dialog-buttonpane').find('button:first').hide();
Upvotes: 1
Reputation: 3411
Try below to get handle to all buttons and then loop through them to hide.
var buttons = $("#divName").dialog('option', 'buttons');
Upvotes: 0
Reputation: 339786
Use:
$('#divName').siblings('.ui-dialog-buttonpane').find('button').eq(n).hide();
where n
is the number of the button in your dialog (starting from zero)
Upvotes: 2