Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Importing a javascript file

Want to import a javascript file with the functions to be used in app.

 

Trying to import using the following.

 

import "local:///assets/global.js" as js

 

It stops my app from working, what is the correct syntax to do this?

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 16,998
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Importing a javascript file

try "global.js" only
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Importing a javascript file

Tried that as well, no luck.
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Highlighted
Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: Importing a javascript file

[ Edited ]

Import it by declaring:

 

import "global.js" as GlobalFunctions

 Then call your functions within QML signals like:

 

GlobalFunctions.nameOfFunction();

 Example here: http://bbcascades.com/index.php/tutorial-list/59-javascript-3-ways (3rd example in the article)

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan