0

I don't understand whats wrong. Trying to learn from the Sencha doc's

app/model/Customer.js

Ext.define('myapp.model.Customer', {
    extend: 'Ext.data.Model',
    fields: ['id', 'name'],
    proxy: {
         type: 'rest',
         url: 'data/customer'
    }
});

app/controller/myController.js

Ext.define('myapp.controller.myController', {
    extend: 'Ext.app.Controller',
    models: ['Customer'],
    ...
    onSomeEvent: function() {
        var cust = Ext.create('Customer', {name: 'neo'});
        cust.save();    
    }
});

I'm getting an Uncaught TypeError: object is not a function error, and my server is logging a GET /Customer.js?_dc=1395954443

Colin
  • 1,835
  • 4
  • 24
  • 29

1 Answers1

2

It seems like error is getting thrown when you are creating model instance.

To create a model instance, you will need to use fully qualified model name i.e.

var cust = Ext.create('myapp.model.Customer')

Or you could this:

var cust = this.getCustomerModel().create()
player
  • 610
  • 6
  • 15
  • the first one works. the second throws an error because `getCusotmerModel()` wasn't generated. Thanks for your time and effort - I just wish things worked like in Sencha's examples. – Colin Aug 29 '13 at 18:34
  • Glad it worked for you. The second one will only work if your controller has models:['Customer'] declaration. Checkout the "Generated getter methods" section in http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.app.Controller-cfg-models – player Aug 29 '13 at 22:56