Im fairly new to backbone and running into a weird problem
I have a model that looks like so:
define( function ( require, exports, module )
{
"use strict";
var Backbone = require( 'backbone' );
return Backbone.Model.extend(
{
defaults: {
isLoggedin: false
},
url: 'http://api.com/login',
parse: function( data ){
//do stuff based on call
},
initialize: function(){
},
doLogin: function( data ){
this.fetch({
data: data,
type: 'POST'
});
this.isUserLoggedIn();
},
isUserLoggedIn: function(){
this.fetch({
url:'http://api.com/loggedIn',
type: 'GET'
});
}
doLogout: function () {
this.fetch({
url:'http://api.com/logout',
type: 'POST'
});
}
});
} );
As you can see i have 3 different functions happening what i need to do is based on the function i need to do different actions or return different results but with having one parse function how can i know which function is being called to do whatever i need in the parse. For example if isUserLoggedIn function is called i need to redirect them to some page based on response if doLogout is called i need to redirect them to another page based on response. Any ideas?