3

我正在使用 MVC 结构在 extjs4 中工作,我想将我的 api(创建)代理设置更改为另一个 url。我在这一点上卡住了。这是我的一些代码

 Ext.define('Balaee.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',],
        proxy:
        {
            type:'ajax',
            api:
            {
                read:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin',
                create:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/AuthenticateLogin',
                update:'http://localhost/balaee/Balaee/index.php?r=SocialNetworking/user/Registration'

            },//end of api
            reader:
            {
                type:'json',
            },//end of reader
            writer:
            {
                type:'json',
                root:'records',
            },//End of writer
        }//end of proxy
}

请给我一些建议。

4

1 回答 1

3

Ext.apply你可以用or做这样的事情Ext.applyIf

var userModel = Ext.create('Balaee.model.sn.UserModel',{}),
    proxy = userModel.getProxy();

Ext.apply(proxy.api, {
    create  : '/controller/new',
    read    : '/controller/load',
    update  : '/controller/update',
    destroy : '/controller/destroy_action'
});
于 2013-01-21T11:04:04.090 回答