Andy-H Posted February 11, 2012 Share Posted February 11, 2012 var user = { userID : null, sessID : null, login : function( user, company, pass ) { $.getJSON(APIServer, { 'method' : 'login', 'username' : user, 'company' : company, 'password' : pass }, function(response) { if ( APIresponse.error(response) == false ) { this.userID = response.userID; this.sessID = response.sessID; this.devices.load(); $('#blackout, #logincontainer').fadeOut('fast', function() { $('#login .pass').val(''); $('#device_container').slideDown('fast', function() { $('#map').css('bottom', $('#device_container').css('height')); $('#map').mapping('trigger', 'resize'); }); }); } }); }, logout : function() { this.userID = null; this.sessID = null; APIresponse.error({qry : 'LOGIN'}); }, devices : { load : function() { $.getJSON(APIServer, { 'method' : 'getDevices', 'userID' : this.userID, 'sessID' : this.sessID }, function(response) { console.log(response); }); } } } Just thought I'd try it to see if it worked, basically I only want the devices object to be accessible via the user object, is this possible? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted February 11, 2012 Author Share Posted February 11, 2012 var user = { userID : null, sessID : null, login : function( user, company, pass ) { var me = this; $.getJSON(APIServer, { 'method' : 'login', 'username' : user, 'company' : company, 'password' : pass }, function(response) { if ( APIresponse.error(response) == false ) { me.userID = response.userID; me.sessID = response.sessID; me.devices.load.call(me); $('#blackout, #logincontainer').fadeOut('fast', function() { $('#login .pass').val(''); $('#device_container').slideDown('fast', function() { $('#map').css('bottom', $('#device_container').css('height')); $('#map').mapping('trigger', 'resize'); }); }); } }); }, logout : function() { this.userID = null; this.sessID = null; APIresponse.error({qry : 'LOGIN'}); }, devices : { load : function() { $.getJSON(APIServer, { 'method' : 'getDevices', 'userID' : this.userID, 'sessID' : this.sessID }, function(response) { console.log(response); }); } } } I was calling this inside getJSON, *facepalm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.