If you really wnat a global, remember that you also always can write
it like this:

window.pagetab = $("#tabarea > ul").tabs( tabcfg );

Thats saves you the var declaration outside the ready handler. Not
much of a difference but may be easier. May also be less obvious
though, because you potentially don't have globals in one place.

--Klaus


On Sep 11, 9:02 pm, Brad <[EMAIL PROTECTED]> wrote:
> SOLVED. I swear that I tried this yesterday and it didn't work . When
> that happened I figured there was some complicated solution. :(
>
> var LOCATIONS_TAB = 3; // one of many pseudo constans.
>
> var tabcfg = {
>           selected: 0
>         , disabled:[2]
>         , spinner:''
>         , cache:true
>         , ajaxOptions: { cache: false }
>         , load: handleTabLoad
>         , select: handleTabSelect
>         , show: handleTabShow
>
> }
>
> var pagetab = null; // <== MAIN PAGE TAB. Init'd when page ready.
> ...
>
> function handleTabLoad(e,ui) {
>   $("#ship_loc_tab_link").bind("click",
>       function(ui){
>         pagetab .tabs('select',LOCATIONS_TAB);
>         return false;
>       }
>   );
>   ...
>
> }
>
> ...
>
> $(document).ready(function() {
>     pagetab = $("#tabarea > ul").tabs( tabcfg );
>     ...
>
> }
>
> On Sep 11, 12:39 pm, Brad <[EMAIL PROTECTED]> wrote:
>
> > Klaus,
>
> > The problem is with the way my code is organized.
> > Since $tabs is defined in the $(document).ready it isn't globally
> > accessible in handleTabLoad or other functions.
>
> > Below is a paired down example of my code. Thanks for you help. Your
> > other suggestions worked nicely.
>
> > -- Brad
>
> > var LOCATIONS_TAB = 3; // one of many pseudo constans.
>
> > var tabcfg = {
> >           selected: 0
> >         , disabled:[2]
> >         , spinner:''
> >         , cache:true
> >         , ajaxOptions: { cache: false }
> >         , load: handleTabLoad
> >         , select: handleTabSelect
> >         , show: handleTabShow
>
> > }
>
> > ...
>
> > function handleTabLoad(e,ui) {
>
> > $("#ship_loc_tab_link").bind("click",
> >   function(ui){
> >     // I simply want to switch tabs when this link is clicked
> >     // I'd like to do this, but it doesn't work
> >     $tabs.tabs('select',LOCATIONS_TAB);  // Assuming $tabs is global,
> > but it isn't
> >     return false;
>
> >     // What I have to do to make it work
> >     tabcfg.selected = ui.index;
> >     $tabs = $("#tabarea > ul").tabs(tabcfg);  // Finding $tabs again!
> >     $tabs.tabs('select',LOCATIONS_TAB);
> >     return false; // don't submit form
>
> >   });
>
> > }
>
> > ...
>
> > $(document).ready(function() {
> >     var $tabs = $("#tabarea > ul").tabs( tabcfg );
> >     ...
>
> > }
>
> > On Sep 11, 10:16 am, Klaus Hartl <[EMAIL PROTECTED]> wrote:
>
> > > On Sep 11, 5:47 pm, Brad <[EMAIL PROTECTED]> wrote:
>
> > > > var $tabs = $('#example > ul').tabs(tabcfg); // first tab selected
>
> > > > Since this is a single page application I would like to grab and store
> > > > a global reference to the tab control on creation, instead of having
> > > > to get the reference each time I need it (which will be often). Is
> > > > there a way to do that?
>
> > > $tabs is your reference as far as I can see...
>
> > > --Klaus
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to