I am working in extjs4 MVC, where I have a problem when I am storing data using a local storage, and I am going to change the proxy type dynamically from ajax to localStorage.
After setting the data to localstorage I got a error Uncaught TypeError: undefined is not a function.
My model:
Ext.define('Am.model.sn.UserModel',{
extend: 'Ext.data.Model',
//idproperty:'userId',//fields property first position pk.
fields: ['userId','firstName','middleName','lastName','languageId','primaryEmail','birthDate','password','securityQuestionId','securityQuestionAnswer','isMale','creationTime','ipAddress','confirmationCode','userStatusId']
});
My controller:
Ext.define('Am.controller.sn.UserController1',
{
init:function()
{
console.log('Initialized Users! This happens before the Application launch function is called');
this.control(
{
...
});
},
remeberMe : function()
{
console.log("check box selected");
var email=this.getUserName().getValue();
var password=this.getPassword().getValue();
console.log("email="+email);
var objCheckBox=Ext.getCmp('checkbox');
if(objCheckBox.getValue()==true)
{
window.localStorage.clear();
// Here I am getting error Uncaught TypeError: undefined is not a function
var lsProxy = new Ext.data.proxy.LocalStorage({
id: 'localp',
type:'localstorage',
});
var modelObject = Ext.ModelManager.create(
{
primaryEmail:email,
password: password,
proxy:lsProxy
}, 'Balaee.model.sn.UserModel');
modelObject.setProxy(lsProxy);
modelObject.save();
} else {
console.log("check box is not selected");
}
},
});
Please give me suggestion...
First off, if I understand your code correctly - you are loading the users and their passwords to the client side. This is a massive security risk as anyone can see this data (with a few mouse clicks).
Second, LocalStorage
doesn't have a type
config.
Third, if you are really getting the error on this line (and not some sub line in the call stack):
var lsProxy = new Ext.data.proxy.LocalStorage({
Than it can only be that the Ext.data.proxy
is not in scope.
Try to add to your controller this config:
requires: ['Ext.data.proxy.LocalStorage'],
Let us know what happens.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.