简体   繁体   English

Uncaught TypeError:extjs4中未定义undefined吗?

[英]Uncaught TypeError: undefined is not a function in extjs4?

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. 我正在extjs4 MVC中工作,当我使用本地存储存储数据时遇到问题,并且我打算将代理类型从ajax动态更改为localStorage。

After setting the data to localstorage I got a error Uncaught TypeError: undefined is not a function. 将数据设置为localstorage后,出现错误Uncaught TypeError:undefined不是函数。

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. 其次, LocalStorage没有type配置。

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. 只能是Ext.data.proxy不在范围内。

Try to add to your controller this config: 尝试将以下配置添加到您的控制器:

requires: ['Ext.data.proxy.LocalStorage'],

Let us know what happens. 让我们知道会发生什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM