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 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,551
    Answers
    3931
    Vote Rating
    1271
      0  

    Default

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

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  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,551
    Answers
    3931
    Vote Rating
    1271
      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! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •