I'm having problem with updating my App object properties value! I'm trying to update the 'visible' property from false to true whenever I'm calling methods within my App object!
Now I can't figure out why I can't update the values!!! Could somebody please help me?
Here is the code;
var app = app || {};
app.layout = {
// SIDEBAR
'sidebar': function(a) {
var options = {
'settings': {
'object': $('.sidebar-left'),
'visible': false,
'type': 'wide'
},
'open': function() {
if(options.isActive() === false) {
options.settings.visible = true;
options.settings.object.addClass('active');
}
},
'close': function() {
if(options.isActive() === true) {
options.settings.visible = false;
options.settings.object.removeClass('active');
}
},
'isActive': function() {
if(options.settings.visible === true) {
return true;
} else {
return false;
}
}
}
return options[a];
}
// HEADER
// CONTENT
// FOOTER
}
The idea behind this little App API is that I don't need to go and manually check whether a container is visible and change the UI manually, I could just call the app.layout methods and that should do the job...
As you can see, I'm trying to update the 'visible' property value when the two methods of app.layout.sidebar('open')();
and app.layout.sidebar('close')();
are called!
Thank you
Here is the updated version:
http://jsfiddle.net/Farzad/ndb1490v/3/
Hope it helps those that are looking to integrate this to their app, as it makes it really easy to keep track of your UI without needing you to manually check every time...
However if anybody knows any better approach then make an update to the jsFiddle version and link back in the comments section :)
Thank you guys, specially those who being helpful Cheers