PDA

View Full Version : how to access custom class



chitgoks
6 Sep 2012, 7:51 PM
hi, new to sencha here. i have some predefined javascript functions e.g.

test.js
function getString() {
alert('sample');
}

placed it under model/myfolder/test.js

and within a view javascript file, i want to call and get the value of getString() in test.js

i tried to use ext.requires , it does not work

i tried to instantiate it like
var t = Ext.create('MyProj.model.myfolder.test');

but it looks like it does not work still

is this even possible?

vietits
6 Sep 2012, 10:51 PM
You should include your script file by using <SCRIPT> tag embedded in HTML file.

chitgoks
6 Sep 2012, 10:57 PM
ive read that putting it within the index.html is not advisable.

however, i managed to find a solution. place it in the app.json


"js": [
{
"path": "myfolder/myjs.js"
},
],

though i am wondering. if the myfolder has many .js files and iw ant to import all of them, does that mean i have to add an entry of "path": "myfolder/myjs1.js" 1 by 1?

vietits
6 Sep 2012, 11:09 PM
It seems that this is your own solution. I don't know how it work so it's hard to give out a suggestion.

chitgoks
6 Sep 2012, 11:12 PM
actually this is not my solution, but one that was discussed in the docs. thank you for replying though

scottmartin
7 Sep 2012, 9:08 AM
Please have a look at:
http://www.sencha.com/forum/showthread.php?231354

Scott.