Swap905
Swap905

Reputation: 301

Jquery dialog : Hide the button

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

Answers (7)

Ammar Qadir
Ammar Qadir

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

bang
bang

Reputation: 161

If you're trying to hide the "cancel" button, try this. 

$('.ui-dialog-buttonpane button:contains("cancel")').button().hide();

Upvotes: 16

Beau
Beau

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

This will hide first button:

$('#divName').siblings('.ui-dialog-buttonpane').find('button:first').hide();

Upvotes: 1

Akhi
Akhi

Reputation: 2242

Try this.

$("#divName").css("display","none");

Upvotes: 1

Santosh Gokak
Santosh Gokak

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

Alnitak
Alnitak

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

Related Questions