That's considerably less efficient. You're destroying and creating elements and event handlers every time you open the dialog. It's a small enough size that you won't really notice anything, but in general you should avoid that concept.
On Jul 27, 6:33 am, Carlo Landmeter <[email protected]> wrote: > Thanks for your suggestions. > > Somebody on jquery-en already pointed me in the right direction. > > In the API for dialog button it has this: > > Get or set the buttons option, after init. > > //getter > var buttons = $('.selector').dialog('option', 'buttons'); > //setter > $('.selector').dialog('option', 'buttons', { "Ok": function() { > $(this).dialog("close"); > > So I put this in the click function and it will update the buttons correctly. > > Carlo > > 2009/7/26 Scott González <[email protected]>: > > > > > or you can just move the scope up one level... > > the two lines I changed start with a * and have a comment at the end > > > $(document).ready(function(){ > > * var somevar; // <-- declare the variable up here > > $("#dialog").dialog({ > > autoOpen:false, > > modal:true, > > overlay: {backgroundColor: "#000",opacity: 0.5}, > > resizable:false, > > buttons:{ > > "Delete": function() {window.location = "/home/" + > > somevar ;}, > > "Cancel": function() {$(this).dialog("close");} > > } > > }); > > $(".button").click(function(){ > > $("#ui-dialog-title-dialog").text("Attention"); > > var message = "You are about to do something: "; > > $(".ui-dialog-content").text(message + $(this).attr > > ("id")); > > * somevar = $(this).attr("id"); // <-- removed the > > "var" from this line > > $("#dialog").dialog("open"); > > }); > > }); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
