Hybrid View

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    27
    Vote Rating
    1
    hebr3 is on a distinguished road

      0  

    Default How to include my own javascript files

    How to include my own javascript files


    Hi,
    I want to include my own javascript file into a sencha touch project (having some global constants etc.). To do so I just created the file in the app directory and used in the index.html a
    <script type="text/javascript" src="app/filename.js"></script>
    This works fine with localhost.

    However, as soon as I build a production build and deploy it, I get the error
    GET http:/..../myapp/app/filename.js 404 (not found)
    --> the build does not get the file automatically

    What is the right way of adding my own js-files, so that they automatically become part of the build and are cached on the mobile device?

    Thanks, hebr3

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Vote Rating
    834
    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

      0  

    Default


    If you created your app with Sencha Command then you should not edit index.html. Instead you should add JS files to the js property of app.json.
    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.

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    27
    Vote Rating
    1
    hebr3 is on a distinguished road

      0  

    Default


    I added the files to app.json and indeed, now they get deployed.

    However, if I add the files not to index.html, I get an error in the code referencing to the global variable in one of my files. It seem that in this case I have to add them to index.html.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Vote Rating
    834
    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

      0  

    Default


    If you add it to the js array it won't be included? It won't be put into index.html it will be loaded via an ajax call when you launch the production build.
    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.

  5. #5
    Sencha User
    Join Date
    Sep 2012
    Posts
    5
    Vote Rating
    0
    hguillermo is on a distinguished road

      0  

    Default It is not working in production mode

    It is not working in production mode


    Hi guys,

    I added the js files in the app.json file and it works in development mode. After I created the production mode using the sencha command it doesn't work. The files are not loaded. Is this a bug? I though all files were minified and concatenated in the app.js file.

  6. #6
    Sencha User
    Join Date
    Sep 2012
    Posts
    3
    Vote Rating
    2
    2p0thunder is on a distinguished road

      1  

    Default


    Quote Originally Posted by hguillermo View Post
    Hi guys,

    I added the js files in the app.json file and it works in development mode. After I created the production mode using the sencha command it doesn't work. The files are not loaded. Is this a bug? I though all files were minified and concatenated in the app.js file.
    I can confirm this behaviour, as I am currently having similar problem. I am loading a config.js file with microloader as specified in the app.json. However, the app, while in production mode, complains that the variables from this file are not defined. When I check my localstorage in the Chrome's resources tab, I can see that the config.js file is loaded, but it is loaded last, that is after the app.js, so I figure it is the reason why the app does not really know about the included file.

    I managed to make it working by setting the 'remote' option in app.json to true, like so:
    PHP Code:
    ...
    "js": [
            {
                
    "path""resources/js/config.js",
                
    "remote"true
            
    },
            {
                
    "path""touch/sencha-touch.js"
            
    },
            {
                
    "path""app.js",
                
    "bundle"true,  /* Indicates that all class dependencies are concatenated into this file when build */
                
    "update""delta"
            
    }
        ],
    ... 
    However I take this as a workaround and I would be grateful if someone could advise on how to include the config.js file not as remote and as the first one, so that it can be used for settings in the app.

    Cheers

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi