0

I have jQuery UI tabs using AJAX. My problem is I can't seem to retrieve the url which was loaded inside a tab.

For example - I get URL of loaded tab like this

var links = $("#tabs > ul").find("li a");
var selectedTab = $("#tabs").tabs('option', 'selected');
var url = $.data(links[selectedTab], 'load.tabs');

Where url is the url of currently opened tab.

In the tab I have an AJAX call, which calls the same url but with some parameters, i.e.

$.ajax({
    method: 'GET',
    url = url+'?parameter=value'
});

Once this call is executed, a newly created URL is called, tab is reloaded, but the variable which retrieves the loaded tab url remains the same, which means my parameters are missing.

Ideas?

4
  • Here, we can find with small snippet of code too jqueryui.com/demos/tabs/#ajax Commented Sep 26, 2011 at 9:59
  • What is it exactly you're referring to? Commented Sep 26, 2011 at 10:02
  • I don't think you understood my question, I am loading tabs in AJAX, but I can only obtain initial tab URL, not a new URL if it changes. Commented Sep 26, 2011 at 10:47
  • "In the tab I have an AJAX call...", where in the tab did you make this call? And could you provide all the options in the $.ajax()? Commented Sep 27, 2011 at 12:17

2 Answers 2

1
$("#tabs").tabs({  
    load:  function(event, ui){  
        var anchor = ui.tab.find(".ui-tabs-anchor");  
        var url = anchor.attr('href');  
    }  
}); 

This will save the current tab URL in variable url

Sign up to request clarification or add additional context in comments.

Comments

0

you can keep a global variable for the URL.

1 Comment

I'd have to do that the page that contains tab div definition and that's not really what I want to do...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.