here's an example that may be useful <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(function() { $('.btn').click(function() { //insert whatever you want the button to do here $('#hello').html("I've been changed"); $('.btn').hide(); }); }); </script> </head> <body> <form id="myForm"> <p id="hello">Hello World</p> <button type="button" class="btn">Click Me!</button> </form> </body>
On Jun 27, 5:15 am, cloudsuser <[email protected]> wrote: > Could you please share your full working code(hiding buttong or showing > dynamic button) > > > > > > cjdell wrote: > > > Here is the code to do what you ask: > > > $.extend($.ui.dialog.prototype, { > > 'addbutton': function(buttonName, func) { > > var buttons = this.element.dialog('option', 'buttons'); > > buttons[buttonName] = func; > > this.element.dialog('option', 'buttons', buttons); > > } > > }); > > > $.extend($.ui.dialog.prototype, { > > 'removebutton': function(buttonName) { > > var buttons = this.element.dialog('option', 'buttons'); > > delete buttons[buttonName]; > > this.element.dialog('option', 'buttons', buttons); > > } > > }); > > > Add it into into a helper JS file if you wish. Usage: > > > $('#MyDialog').dialog('removebutton', 'Old Button'); > > $('#MyDialog').dialog('addbutton', 'New Button', newButtonClickFunction); > > > function newButtonClickFunction() { > > alert('You clicked the new button!'); > > } > > > honzaB-3 wrote: > > >> Hi, > > >> I have created a simple modal form in dialog and I want to update the > >> buttons according to some events in the form. More specifically I do > >> an ajax request and I want to remove "Send" button after it's clicked. > > >> Is there a simple way to do this? > > >> Thanks for replies, > > >> Jan Brucek > > >> ----- The dialog is specified like this: > > >> $('#contactform').dialog({ > >> bgiframe: true, > >> autoOpen: false, > >> width: 490, > >> modal: true, > >> overlay: { > >> backgroundColor: '#FFFFFF', > >> opacity: 0.5 > >> }, > >> buttons: { > >> "Send": function() { > >> $('#form_contact_form').ajaxSubmit(contactformoptions); > >> }, > >> "Cancel": function() { > >> $(this).dialog("close"); > >> } > >> } > >> }); > > >> $('#contact_form_link').click(function(){ > >> // REMOVE THE "Send" BUTTON HERE.. HOW? > >> } > > >> --~--~---------~--~----~------------~-------~--~----~ > >> You received this message because you are subscribed to the Google Groups > >> "jQuery UI" group.>> To post to this group, send email > >> [email protected] > >> To unsubscribe from this group, send email > >> to>>[email protected] > >> For more options, visit this group at > >>http://groups.google.com/group/jquery-ui?hl=en > >> -~----------~----~----~----~------~----~------~--~--- > > -- > View this message in > context:http://old.nabble.com/jQuery-dialog-add-remove-button-on-the-fly-tp22... > Sent from the jQuery UI Discussion mailing list archive at Nabble.com. -- You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en.
