Monday, April 16, 2012

Execute functions in order

I want to execute 3 functions in a certain order and I do this:



function nextPage() {
var loading_temp = $('#loading_temp');

loading_temp.show()
.queue(function() {
nextPage980()
.queue(function() {
loading_temp.hide();
$(this).dequeue();
});
$(this).dequeue();
});
}


The '#loading_temp' shows up and then the function executes, but the last function (hide the loading gif) does not execute!



Chrome gives this error: Uncaught TypeError: Cannot call method 'queue' of undefined



The nextPage980() function is this:



function nextPage980() {
var ajax_heading = $('#ajax_heading');
var cur_heading = $('#cur_heading');
var temp_heading = $('.temp_heading');
var temp_heading_first = temp_heading.filter(':first');
var loading_temp = $('#loading_temp');

var htmlHeader = "?????????????";

ajax_heading.attr('class', 'next_temp');
cur_heading.css({'margin-right' : '20px'}).after('<div id="cur_heading" class="temp_heading" data-tempPos="2"><h1 class="page_heading"><span class="heading_span">' + htmlHeader + '</span></h1></div>')
.queue(function() {
ajax_heading.animate({'margin-left' : '-1000px'}, 1000, 'easeInExpo')
.queue(function() {
temp_heading_first.remove();
cur_heading.removeAttr('style');
ajax_heading.attr('class', 'cur_temp').removeAttr('style');
$(this).dequeue();
});
$(this).dequeue();
});
}


Thanks in advance!





No comments:

Post a Comment