0

I want to use an object globally in Backbone Application. I was using jQuery MObile Application before.

To have a global variable, I created a file named Configuration.js which have the scripts,

var MyApp = MyApp || {};
MyApp.Configuration = MyApp.Configuration || {
    OrganizationUniversalId: 'abcd-efgh-1234',
    ServiceEndpoint: 'http://myapp.net/',
    GcmSenderId : "123456789"
};  

From other javascript files, the property can be obtained by MyApp.Configuration.ServiceEndpoint

This seems not to work in my Backbone application, why?

Cisum Inas
  • 11,552
  • 11
  • 40
  • 55
Joseph
  • 1,060
  • 3
  • 22
  • 53
  • What makes you think other js files can't access global variable..? – T J Feb 04 '16 at 07:39
  • If you want to do it, then go for it. Noone should be denied following their dreams. – ivarni Feb 04 '16 at 08:34
  • But if I try to get `MyApp.Configuration.ServiceEndpoint` , its says ServiceEndpoint is undefined – Joseph Feb 04 '16 at 08:41
  • 1
    Most likely the scripts are included in the wrong order then, but it's impossible to know for sure without seeing more of your code. If you can reproduce the error in jsfiddle or somewhere similar that would be good. – ivarni Feb 04 '16 at 10:23

0 Answers0