Reputation: 23
i have the following problem. I'm trying to load a set of tab loading dinamically with jQuery. When I get the new contents (via POST) the tabs() function abort and don't build the tabs. I'm using this functions:
$(document).ready(function() {
var array_with_alias_id = $.getJSON("/getAliasForMatchAll/", null,
function (data){
array = data.aliases_id;
load(array);
});
$("#next_left").click(function(){next_left()});
//load(array_with_alias_id);
});
function next_left(){
if(j >= array.length-1){
var l = j
} else {
var l = j+=1;
}
$("#alias_id_left").val(list_left[l]);
$("#merge_alias_id_left").val(list_left[l]);
$.post("/visor/",{"alias_id":list_left[l],"position":"L"},
function(data){
$("#tabsL").html(data).ready(function(){
$("#tabsL").tabs();
});
});
}
I think that my problem is an ajax problem and i have read this [0], but i can't give with the solution. The function next_left() it works only one time. I think that the document for this function is ready, but when i load the tabs it doesnt work (i think that tab call the method abort, because if i see the html with firebug it change, but not all).
Any clue?
[0]http://docs.jquery.com/Tutorials:AJAX_and_Events
Upvotes: 0
Views: 504
Reputation: 23
People on IRC helped me. I have now changed the function after the .POST to this:
function next_left(){
if(j >= array.length-1) {
var l = j
}
else {
var l = j+=1;
}
$("#alias_id_left").val(list_left[l]);
$("#merge_alias_id_left").val(list_left[l]);
$.post("/visor/",{"alias_id":list_left[l],"position":"L"},
function(data) {
$("#tabsL").html(data).tabs("destroy").tabs();
});
}
They correctly advised me that the ready function applies to the document and does not work how I used it. I hope the fixed code I posted here aids others.
Upvotes: 0
Reputation: 960
Try replacing $("#next_left").click(function(){next_left()}); with:
$("#next_left").live('click', function(){next_left()});
Upvotes: 1