Results 1 to 4 of 4

Thread: Uncaught ReferenceError: generateData is not defined (anonymous function)

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    1
    Vote Rating
    0
      0  

    Default 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 6
    Code:
     data: generateData(6, 2)
    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;
        	}
        }
    });
    Didnt find the right forum so i decided to post here because i use data for charts.

    Thx

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,339
    Answers
    3887
    Vote Rating
    1297
      0  

    Default

    Where do you specify the generateData function?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    91
    Answers
    6
    Vote Rating
    0
      0  

    Default

    It looks like he is specifying it in his onReady function, does that work?

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,339
    Answers
    3887
    Vote Rating
    1297
      0  

    Default

    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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •