Hi Marc... I had a chance to look at the code and to think about this... It does in fact look like all calls are made with Async false if the completefunc is set, as @thamera points out. I did a few test with the code below and watched the sequence of output to the console to validate this...
I think the item that got me is the fact that the async is overwritten. I can't think of a reason to change that based on whether the input options has a completefunc option defined or not.
My suggestion is to always honor the caller's options, in this cased async... The Completefunc should always be executed if defined...
Tested with the following:
I think the item that got me is the fact that the async is overwritten. I can't think of a reason to change that based on whether the input options has a completefunc option defined or not.
My suggestion is to always honor the caller's options, in this cased async... The Completefunc should always be executed if defined...
Tested with the following:
(function(){
$.getScript("http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2013.01/jquery.SPServices-2013.01.min.js");
/**
* Test deferreds from SPServices 2013.01
* Using: http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2013.01/jquery.SPServices-2013.01.min.js
*/
window.test = function() {
console.log("1) Before SPServices (v" + $().SPServices.Version() + ")");
$().SPServices({
operation: "GetListItems",
listName: "states",
async: true,
completefunc: function(){
console.log("3) completefunc() Done!");
}
})
.then(function(){
console.log("4) .then() Done!");
});
console.log("2) After SPServices call...");
}
})(jQuery);
When I removed the completefunc, the ouput I got was the expected one (1,2,4).