jQuery UI tabs - getting URL of tab loaded with Ajax

时光总嘲笑我的痴心妄想 提交于 2019-12-14 04:25:14

问题


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?


回答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




回答2:


you can keep a global variable for the URL.



来源:https://stackoverflow.com/questions/7553363/jquery-ui-tabs-getting-url-of-tab-loaded-with-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!