I use the strophe.archive plugin but the done function of the Deferred object seems to be “undefined” after Strophe sends the query. I also added the plugin to the “shim” of require.js:
var q = $.Deferred();
q = connection.archive.listCollections("user@server.lit");
console.log(q);
q.done(function(){
console.log("DONE");
});
I get the following trace:
Uncaught TypeError: Cannot call method 'done' of undefined test.js:23
Backbone.View.extend.initialize test.js:23
Backbone.View backbone.js:1148
child backbone.js:1393
Backbone.Router.extend.pageTest router.js:92
(anonymous function) backbone.js:900
(anonymous function) backbone.js:1082
_.some._.any underscore.js:193
_.extend.loadUrl backbone.js:1080
_.extend.navigate backbone.js:1125
_.extend.navigate backbone.js:909
Backbone.View.extend.pageTest test1.js:199
jQuery.event.dispatch require-jquery.js:5385
elemData.handle.eventHandle
shim:
archive: {
deps: ["jquery", "strophe"],
exports: "archive"
},
You invoke a deferred obj and assign it to
q, and then you assign the result oflistCollectionstoq. These are two different and completely unrelated assignments. Just because you madeqa deferred initially doesn’t mean that the result fromlistCollectionsis now somehowdeferrable.listCollectionsmust return a deferred object for you to be able to calldoneon it.Looking at the plugin code, it looks like
listCollectionsdoesn’t return anything.Instead, you must pass
listCollectionsa callback function:Alternatively, you can make a wrapper function for
listCollectionsthat will return a deferred.No you can call something similar to your original code: