Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format
Am I able to use an external Js resource in Sencha Native app?
Architect Build tested:
Steps to reproduce the problem:
- I've created a very simple native app using Sencha Architect/Sencha Touch 2.1. I added a JS Resource. The JS file only declares a global variable. I find that I can access the variable in the JS resource if I bring up the app in a browser. If I create a native app and try to bring up the variable value (through a message box or something similar), I find that the variable is inaccessible. Is it possible to access an external JS resource code in a native app?
The result that was expected:
- Create a simple application with a JS Resource that contains a global variable with a string value.
- Use something like a message box to display the variable value.
- Create a native app and try the application in the iOS simulator (or on your iPad or iPhone).
The result that occurs instead:
- I expect to be able to use a JS resource.
- Unable to use the JS resource
Be sure that the index.html file that gets created when you package has been updated from the app.html. If you add the js resource after Architect made a copy of the app.html > index.html it will not again update it. This is because we wouldn't want you to lose any customizations.
Be sure index.html has the script include
Thanks that was it. A nice enhancement might be to recognize if there are no customizations to automatically update the index.html or at least to let the user know to make sure to update the file.
Thanks for the help.
It's very subtle but you do get a notification to update that file when you run package build/simulate
I agree we should improve this step
You are correct. The message makes sense now. Unfortunately, the terminal window that gives the updates of the build usually covers the message and the message goes away too quickly. Also, by the time the message comes up, isn't it "too late"? Meaning the build has already used the out of date index.html?
*sheepish* yes it's too late.
Any ideas for improved workflow?
If not index.html exists this is when we create one.
I suspect in the near future we'll be building using Sencha Cmd which creates a whole different folder build/theme/production as an example
I would suggest using the "Sencha Cmd Setup" dialog in Sencha Architect to improve the workflow for recognizing and needing to update the index.html that is generated. At the very least, putting the warning on the dialog would notify the user prior to the user hitting the "Simulate" or "Build" buttons. Optionally, you can give us a button to "regenerate" the index.html (and obviously overwrite the user's changes). Another idea is to give us a way to hand edit the index.html file from this dialog (without needing to go to some other editor).