1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    4
    Vote Rating
    2
    tonyhansen is on a distinguished road

      0  

    Default n00b question: how to add to Ex.application "requires" section?

    n00b question: how to add to Ex.application "requires" section?


    Hi All,

    So I've followed the "First Touch Application" tutorial, and get pretty much nothing on screen, other than the header.

    Chrome reports this error:

    "Uncaught TypeError: Cannot call method 'setStore' of undefined"

    Comparing my work to the "CityBars670" sample download, I see the sample has this section under the code for "Application":

    <snip>

    Ext.Loader.setConfig({
    enabled: true
    });Ext.application({
    requires: [
    'Ext.dataview.List',
    'Ext.data.proxy.JsonP'
    ],

    models: [
    'Business'
    ],
    </snip>

    whereas my app is missing that.

    I can't simply type it in to add it ... can someone please tell me, step by step, how I go about adding this "requires" section to my app?

    Sorry if this is a complete n00b question ... learning this stuff at 5am, so maybe my head isn't screwed on properly ;-)

    Thanks!

    T

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,247
    Vote Rating
    121
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Click the application node in the inspector; in the configuration grid at the bottom right search for "requires" then add any particular requires you want.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    4
    Vote Rating
    2
    tonyhansen is on a distinguished road

      1  

    Default


    Thanks so much for that Aaron.

    I was sure I had tried that, but the filter wasn't returning the "requires" configuration item. Obviously I was doing something wrong ... probably had the wrong item selected in the Inspector.

    All fixed now. Ended up getting my version of the CityBars sample project up and running, after a few more fixes related to id casings, so all good!

    Thanks!

    T

  4. #4
    Sencha User
    Join Date
    Nov 2012
    Posts
    4
    Vote Rating
    2
    tonyhansen is on a distinguished road

      1  

    Default


    One more question on this subject ... how would I know what/when to add to the "requires" section?

    There's nothing about modifying that section in the walkthrough for the CityBars sample application ... if it wasn't for doing a line-by-line comparison to the existing working demo download, I never would have realised I needed those entries.

    I had assumed that by adding the components to the designer surface, the necessary "requires" would be automagically populated. Not the case?

    Thanks

    T

  5. #5
    Touch Premium Member BostonMerlin's Avatar
    Join Date
    Aug 2010
    Location
    Boston
    Posts
    522
    Vote Rating
    41
    BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about

      0  

    Default


    Requires are typically added automatically. Sometimes this doesn't always work though.

  6. #6
    Sencha User
    Join Date
    Nov 2012
    Posts
    4
    Vote Rating
    2
    tonyhansen is on a distinguished road

      0  

    Default


    Cheers mate.

    Is there a list/guide somewhere, that says "if you use THIS component, then you should have THIS requires"? In case another "doesn't always work" situation arises?

    I'm flying blind ... if this hadn't been demo code that I could compare to a pre-built example, I would have been buggered trying to work out what the problem was.

  7. #7
    Sencha - Architect Dev Team Phil.Strong's Avatar
    Join Date
    Mar 2007
    Location
    Olney, MD
    Posts
    1,898
    Vote Rating
    62
    Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice Phil.Strong is just really nice

      0  

    Default


    Requires are simple but seemingly hard to explain.

    A few examples:

    If a store uses a particular model then it would need to require that model to be loaded before it's defined.

    If you have a view that instantiates another view by name or xtype then you'd need to require it.

    In general, the framework should do a good job telling you that files we're loaded in the correct order if you do it wrong.

    Application requires are slightly different in that it says here's all my stuff. It's up to you if you want to require only top level classes and have them require what they need or simply require everything.
    Phil Strong
    @philstrong
    #SenchaArchitect
    Sencha Architect Development Team