Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>In tracing the script above in FireBug, once the location.href=url is executed the new page loads and the return statements are never executed. Is this a problem?</p> </blockquote> <p>After you do <code>location.href=url</code> you leave the page and current code stops executing.</p> <p>From your code you cannot know which page is current to select it. You need to add CSS selector to the current element that indicates that or load content via AJAX.</p> <hr> <p>TO SELECT CURRENT TAB:</p> <p>First thing you need to know is which page corresponds to which tab. As you haven't provided such information I will just assume that URL has <code>tab</code> parameter that defines selected tab.</p> <p>You need to provide the index of currenttab in the ASPX (todo: validate QueryString):</p> <pre><code>&lt;%= string.Format("var currentTab = {0};", Request.QueryString["tab"]) =&gt; </code></pre> <p>And in your JavaScript use this code:</p> <pre><code>$('#example').tabs({ selected: currentTab || 0, select: function(event, ui) { var url = $.data(ui.tab, 'load.tabs'); if(url) { location.href = url + "?tab=" + ui.index; return false; } return true; } }); </code></pre> <p>But please:</p> <blockquote> <p>Note that opening a tab in a new window is unexpected, e.g. inconsistent behaviour exposing a usablity problem (<a href="http://www.useit.com/alertbox/tabs.html" rel="nofollow noreferrer">http://www.useit.com/alertbox/tabs.html</a>).</p> </blockquote> <hr> <p>TO LOAD TAB VIA AJAX:</p> <p>I do not know where you could find the code you posted in the jQuery docs, but that is incorrect one.</p> <p>According to the <a href="http://jqueryui.com/demos/tabs/#Ajax_mode" rel="nofollow noreferrer">docs</a>:</p> <blockquote> <p>Tabs supports loading tab content via Ajax in an unobtrusive manner.</p> <p>The HTML you need is slightly different from the one that is used for static tabs: A <strong>list of links</strong> pointing to existing resources (from where the content gets loaded) and no <strong>additional containers at all</strong> (unobtrusive!). The containers' markup is going to be created on the fly:</p> </blockquote> <p>So the HTML should be:</p> <pre><code>&lt;div id="example"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="ahah_1.html"&gt;&lt;span&gt;Content 1&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="ahah_2.html"&gt;&lt;span&gt;Content 2&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="ahah_3.html"&gt;&lt;span&gt;Content 3&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>and the JavaScript should be:</p> <pre><code>$(function() { $("#example").tabs(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload