1. #1
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default Unanswered: Properly destroy extended instances

    Unanswered: Properly destroy extended instances


    I have some trouble with models and controllers after destroying them. Custom members seam to be there on every other instance.

    For example, if I have a model:

    Code:
    Ext.define('MyApp.model.Payment',{
        extend:'Ext.data.Model' ,
        config:{
            beneficiary:null,
            account:null,
            currency:null,
            remaining:null,
            category:null,
            details:null,
            fields:[
            {
                name: "creditorAccount",
                type: "string"
            },
    
    
            {
                name: "debtorAccount",
                type: "string"
            },
    
    
            {
                name: "amount",
                type: "number"
            },
    
    
            {
                name: "details"
                
            },
    
    
            {
                name: "category",
                type: "string"
            },
            ],
            validations:[
            {
                type: 'presence',
                field: 'creditorAccount'
            },
    
    
            {
                type: 'presence',
                field: 'amount'
            },
    
    
            {
                type: 'presence',
                field: 'debtorAccount'
            }
            ]
        }
    });
    First instance of this model type will not have any references to beneficiary, account, and the others. But if I set them, and then destroy the instance, all the future instances of this model will already have some references to these members (named _beneficiary, _account, etc) though they are fresh new instances and I would expect them to be empty as the first one.

    ( Also there is a bug on the framework, I think, destroying a model makes its private member named `modified` null, and this will cause an error on a new instance of this type, because there is a object expected in that member. )

    I had overwrite the destroy method for the model, to manually set my custom members to null, that is not enough it seams, the '_' underscore references are still there.

    So, how do you properly destroy a (model) instance?

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,780
    Answers
    3465
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The model instance should have a destroy() method.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    As I said, it has a destroy method...




    Code:
    Ext.define('MyApp.model.Payment',{
        extend:'Ext.data.Model' ,
        config:{
            beneficiary:null,
            account:null,
            currency:null,
            remaining:null,
            category:null,
            details:null,
            fields:[
            {
                name: "creditorAccount",
                type: "string"
            },
    
    
            {
                name: "debtorAccount",
                type: "string"
            },
    
    
            {
                name: "amount",
                type: "number"
            },
    
    
            {
                name: "details"
                
            },
    
    
            {
                name: "category",
                type: "string"
            },
            ],
            validations:[
            {
                type: 'presence',
                field: 'creditorAccount'
            },
    
    
            {
                type: 'presence',
                field: 'amount'
            },
    
    
            {
                type: 'presence',
                field: 'debtorAccount'
            }
            ]
        },
     
        destroy:function()
        {
            this.setBeneficiary(null);
            this.setAccount(null);
            this.setCurrency(null);
            this.setRemaining(null);
            this.setCategory(null);
            this.setDetails(null);
            this.callParent(arguments);
            this.modified= {};
        }
    });
    First instance has data and _data an everything a model normally has, every other instances receive some _my_defined_members also.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi