-
11 Jun 2012 5:36 AM #1
Unanswered: Uncaught ReferenceError: generateData is not defined (anonymous function)
Unanswered: Uncaught ReferenceError: generateData is not defined (anonymous function)
First my noobie question:
Why my function cant be used?
Uncaught ReferenceError: generateData is not defined (anonymous function) on line 6Code:data: generateData(6, 2)
Didnt find the right forum so i decided to post here because i use data for charts.Code:Ext.define('MyApp.store.ChartStore', { extend: 'Ext.data.Store', config: { fields: ['name', '2007'], data: generateData(6, 2) }, onReady: function(){ this.generateData = function(n, floor) { var data = [], p = (Math.random() * 11) + 1, i; floor = (!floor && floor !== 0) ? 20 : floor; for (i = 0; i < (n || 12); i++) { data.push({ name: Date.monthNames[i % 12], 2007: Math.floor(Math.max((Math.random() * 100), floor)) }); } return data; } } });
Thx
-
13 Jun 2012 9:01 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
- Answers
- 3113
Where do you specify the generateData function?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
27 Dec 2012 2:49 PM #3
It looks like he is specifying it in his onReady function, does that work?
-
28 Dec 2012 6:58 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,710
- Vote Rating
- 436
- Answers
- 3113
That's never going to work. The way you are using generateData it's expecting some global or local to the file function not a function on the scope of the store. Also, onReady on a class is not used by the framework.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote