Thanks--that did it! I naively assumed that the scope of the variable would apply throughout the code block since everything was contained within the document.ready function...
Thanks again, AO On Sep 8, 2:38 pm, Fontzter <[email protected]> wrote: > You could just move your variable out so that it has scope in both > places. (see below) Also, you may want to return false from the click > event to prevent the click event from following through anyway. > > Hth, > > Dave > > <script language="javascript" type="text/javascript"> > > var button_url; > > $(document).ready(function() { > $('#dialogTest').dialog({ > autoOpen: false, > modal: true, > buttons: { > "Continue": function () { > $(this).dialog("close"); > window.location=button_url; > } > } > }); > > $('.bttn').click(function() { > button_url = $(this).attr('href'); > $('#dialogTest').dialog('open'); > return false; > }); > }); > </script> > > On Sep 8, 1:59 pm, ao <[email protected]> wrote: > > > Hi all, > > > I'm a new user to jquery/jqueryUI and am trying to use a dialog to > > display a message before forwarding the user to a new page. As I've > > tried to set it up, the user will click on one of a number of buttons > > of a certain class. The href attribute of the button will be stored in > > a variable, then the dialog box will be shown. When the user hits the > > continue button within the dialog, the dialog will close and we will > > be forwarded to the URL stored in the variable. > > > Here is the relevant code: > > > <script language="javascript" type="text/javascript"> > > $(document).ready(function() { > > $('#dialogTest').dialog({ > > autoOpen: false, > > modal: true, > > buttons: { > > "Continue": function () { > > $(this).dialog("close"); > > window.location=button_url; > > } > > } > > }); > > > $('.bttn').click(function() { > > var button_url = $(this).attr('href'); > > $('#dialogTest').dialog('open'); > > }); > > }); > > </script> > > > <button class="bttn" href="www.google.com" value="Open the > > Dialog">Open the Dialog</button> > > > <div id="dialogTest" title="Testing...">Clicking continue should > > forward us to google.com, the href of the button....</div> > > > Unfortunately, the variable is never set; have I misused the attr > > function? > > > Thanks for any suggestions! > > AO --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
