1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    3
    Vote Rating
    0
    APPrentice is on a distinguished road

      0  

    Default Answered: Dynamicly added <script> Tag in Header, now i need to load it..

    Answered: Dynamicly added <script> Tag in Header, now i need to load it..


    I got two Language Files
    • DrBudjet_EN.js
    • DrBudjet_DE.js
    After selecting a language from my picker, i add the corresponding script to the header

    Code:
    var th = document.getElementsByTagName('head')[0];
    var s = document.createElement('script');
    s.setAttribute('type','text/javascript');
    s.setAttribute('src','app/translate/DrBudjet_DE.js');           // right now fix value
    th.appendChild(s);
    After i added it to the Header. (I checked it and its there)

    I want to load my App...

    Code:
    Ext.Viewport.add(Ext.create('DrBudjet.view.Main'));
    But this alone doesn't work, because somehow the freshly added <script> hasn't been read.

    LANG_defined.png

    If i now use the firebug console and type in

    Code:
    Ext.Viewport.add(Ext.create('DrBudjet.view.Main'));
    for the second time it works.

    The LANG is now defined and my APP is running with the correct Language.

    What do i have to do to only create the new View once?

    Thank you for your help in advance
    Last edited by APPrentice; 19 Apr 2013 at 3:14 AM. Reason: image added

  2. Use the onLoad property of the <script> element you created

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    Are you waiting for the <script> to load before adding the view to the viewport?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    3
    Vote Rating
    0
    APPrentice is on a distinguished road

      0  

    Default


    Oh.. might that already be the answer, sounds correct to me.
    How can i wait for the script to get loaded?

    Thanks in advance

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    Use the onLoad property of the <script> element you created
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread