Sencha Touch: perform read (load) operation from singleton model

106 Views Asked by At

I have a singleton model and an associated AJAX proxy.

If I make a call to MyModel.load(), I get the error:

MyModel.load is not a function

However, you do have load in Model:

http://docs.sencha.com/touch/2.4/2.4.1-apidocs/#!/api/Ext.data.Model-static-method-load

On the contrary, MyModel.save() exists and I can access it.

Is this a bug or am I missing something?

1

There are 1 best solutions below

1
On BEST ANSWER

The load method listed on Ext.data.Model is a static method on the class definition, not an instance. The documentation even denotes this is a static method. When you want to load a record, you don't load an already instantiated record, you load the model definition and that loading creates an instance.

The save method listed on Ext.data.Model is an instance method, the docs do not denote this as a static method. You don't save a class definition, you save an instance.

Example usage: https://fiddle.sencha.com/#fiddle/lvj