javascript - $.when with multiple fetch() breaks backbone model -


i trying use $.when() in project.
if write like:

    var gettaskinfo = new task({'id': task_id}).fetch();      $.when(gettaskinfo).then(function (obj1) {         console.log(obj1);     }); 

console output gives me:

object {id: 1, task_type_id: "1", project_id: "1", order_in_project: 1, main_answer_id: "1"…} 

and works fine

but when try use multiple fetches()

    var gettaskinfo = new task({'id': task_id}).fetch();     var getallanswers = new taskanswers(null, {'task_id': task_id}).fetch();      $.when(gettaskinfo, getallanswers).then(function (obj1, obj2) {         console.log(obj1);     }); 

console output shows me obj1 is:

[object, "success", object] 0: object 1: "success" 2: object length: 3 

that isn't object waiting for.
doing wrong? expect obj1 gives me output in first case.

try accessing objects @ .then()

$.when(gettaskinfo, getallanswers).then(function (obj1, obj2) {     console.log(obj1[0], obj2[0]); }); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -