I have a view.js and a model called user.js
user.js :
define( function ( require, exports, module )
{
"use strict";
var Backbone = require( 'backbone' );
return Backbone.Model.extend({
defaults: {
flush: false
},
doRejectBatch: function( batchId, flushToConveyer ){
this.functionName = 'doRejectBatch';
this.flush = flushToConveyer;
this.fetch({
type: 'GET',
url:'http://api.com/reject/' + id +'/rej',
xhrFields: {
withCredentials: true
}
});
},
doPatchBatch: function( batchuuid ){
var patchData = {
"status": "rejected",
"jobs_to_conveyer": this.flush
};
this.fetch({
type: 'PATCH',
url: 'http://api.com/api/rej/' + uuid,
contentType: 'application/json',
data: JSON.stringify(patchData),
xhrFields: {
withCredentials: true
}
})
}
});
} );
When a function is complete the onSync
function in my view.js is called.
onSync: function ( rawData, response ){
var msg = "Reject Request: successfull";
app.regionMessage.show(new MessageView({
model: new Backbone.Model({
msg_type: response[0].status,
msg: msg
})
}));
}
});
How can I determine in the view.js onSync
function which functions response is sent from the model? In other words was the doRejectBatch
function used or is the response from the doPatchBatch
function? Note that the view.js is actually the controller and not really a view