PDA

View Full Version : [INFOREQ] Am I able to use an external Js resource in Sencha Native app?



Trayak
20 Nov 2012, 7:14 AM
REQUIRED INFORMATION
Architect Build tested:

Build: 676
Project Type:

Touch 2.1
Description:

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?
Steps to reproduce the problem:

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 was expected:

I expect to be able to use a JS resource.
The result that occurs instead:

Unable to use the JS resource
Operating System:

Mac OSX

Phil.Strong
20 Nov 2012, 7:58 AM
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

Trayak
20 Nov 2012, 8:31 AM
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.

Brian

Phil.Strong
20 Nov 2012, 8:48 AM
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

Trayak
20 Nov 2012, 9:56 AM
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?

Thanks,

Brian

Phil.Strong
21 Nov 2012, 11:26 AM
*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

Trayak
27 Nov 2012, 6:44 AM
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).

Brian