javascript - Using jquery's .queue to queue functions -
when remove parameter 'ajax' from .queue()
function, ajax calls queued. problem is, jquery docs .queue()
function default 'fx' queue. unfortunately, using queue (for effects) , want use queue custom functions. unfortunately, code inside .queue()
function never gets called. have example of code below (just small snippet). getting little complicated if have further questions feel free comment.
$(document).ready(function(event) { var target = event.target; var ajaxify = new ajaxify(); $.each(ajaxify.functions, function(index, value){ if ($(target).hasclass(value)) { console.log('this in console, , else in code'); $('#main').queue('customfunctions', function (next) { var self = this; ajaxify[value](target, event, next, self); }); } }); $('#main').dequeue('customfunctions'); }); function ajaxify() { this.functions = [ 'ajaxify_overlay', 'ajaxify_overlaycancel', 'ajaxify_overlaysubmit', 'ajaxify_rollout', 'ajaxify_rolloutcancel', 'ajaxify_rolloutsubmit', 'ajaxify_upload', 'ajaxify_contentarea', 'ajaxify_itemtoggler', 'ajaxify_closer', 'ajaxify_submit', 'ajaxify_inputactivate', 'ajaxify_executeandrefresh', 'ajaxify_empty' //no comma on last entry!!!! ]; } ajaxify.prototype.ajaxify_executeandrefresh = function (target, event, next, self) { event.preventdefault(); var newpath = getvar($(target).attr('class'), 'url'); //getvar function not included, new path ajax call below var url = $(target).attr('href'); $.ajax({ type: "post", url: url, success: function(transport) { refreshpage(newpath); //refreshpage function not included, page refresh new path next(); } }); }
you need call dequeue()
run next function in queue.
Comments
Post a Comment