locked
JS files management and Intellisense RRS feed

  • Question

  • Hi,

    I'm building a multi page application and I'm asking some questions about JS files management.

    I've declared my app's JS files in default.html, and some in my home.html file. My question is the followinng : why does Intellisense not recognize the classes declared in default.html when I work in home.js ? This wouldn't have been a problem if the mentionned classes were not present in home.js 's scope, but in fact they are and the only thing that is not working is Intellisense (no auto-completion).

    I have to precise that I mainly use the "module" pattern in my JS files :

    (function() {
    
    	var MyClass = WinJS.Class.define({.....});
    
    	WinJS.Namespace.define('MyApp', {MyClass: MyClass});
    
    })();

    If the scope were destroyed when loading a new page like in "real life", I would understand that behavior, but it is not the case, and redeclaring JS files in pages html seems to be a lack of performances. Also, and as far as I've understood the "navigation template" 's mechanism, the application still remains single page...

    But maybe there is something I'm missing ?


    Sunday, November 24, 2013 11:03 AM

Answers

All replies

  • The class needs to be parsed and in scope for intellisense to work.  There is no performance penalty for including the file in your pages (it all gets compiled down when you build the release version of your app).

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Monday, November 25, 2013 3:47 PM
    Moderator
  • Hi Jeff,

    thanks for answering. I take note about the compilation trick.

    But even if I understand the logic behind what you said, and as a personal consideration, I think that Intellisense should consider the application for what it is : a single page application. I regularly use frameworks like Backbone.js and Ember.js, and as a developer, my first mind is that all JS files should be shared from default.html to pages.

    I just wanted to give my opinion about that...

    Thanks anyway

    Monday, November 25, 2013 5:44 PM