开发者

Make js globally accessible to other dynamically loaded scripts

i am developing an MVC site which has many partials that are dynamically loaded. On my site i have a sort of taskbar which sits at the top of the site.

I would like to be able to access methods and properties from my 'taskbar' from any dynamically loaded script.. What is the best way to go about this?

I understand that it is in scope but is there some preferred way to do namesp开发者_如何学JAVAacing or what is the best practice for handling this kind of issue? thanks!


You need to scope it to the window usually, sometimes this needs to be explicit, sometimes it doesn't, for example:

window.Taskbar = {};

These should be available to use anywhere in your scripts (assuming they're logically in the same window).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜