views:

157

answers:

2
+1  Q: 

jQuery Syntax Help

Sorry for asking such a newbie question, I know it makes a few of you here angry. But I think learning the syntax is the hardest part so don't flame me too badly.

Right, I'm using the Tabs widget from the jQuery UI. I'm stuck with setting the options for this. This is how it stands...

<script type="text/javascript">
$(function() {
    $("#forumswitch").tabs({
     event: 'mouseover',
    });
}); 
</script>

I'm using Ajax with this however I want it to be cached instead of requesting new data each time a tab is changed. (http://docs.jquery.com/UI/Tabs#option-cache)

How would I add this to the settings? I know it's done with arrays but I seem to mess it up every time I try.

+5  A: 

The argument being sent to tabs is a hash/associative array of options. Just add cache: true to this hash.

<script type="text/javascript">
$(function() {
    $("#forumswitch").tabs({
        event: 'mouseover',
        cache: true
    });
}); 
</script>
Evan Meagher
Options: http://jqueryui.com/demos/tabs/#ajax
Jonathan Sampson
Thank you! Seems obvious now. I thought you needed "sub-array" for ajax options. Seems not. Thanks again.
Ben Shelock
Evan, please take away the comma behind the "cache:true", it may cause error in many javascript engines
xandy
+2  A: 
<script type="text/javascript">
$(function() {
    $("#forumswitch").tabs({
        event: 'mouseover',
        cache: true
    });
}); 
</script>
marcc