Ember.js controller variables reseting after page refresh

时光毁灭记忆、已成空白 提交于 2019-12-25 14:39:54

问题


Using Ember.js:

I have a Route

App.QueryDataRoute = Ember.Route.extend({
  model: function(params) {
    return Ember.RSVP.hash({
        propertyObject: this.controllerFor("cres").get("properties").findBy('title', params.propertytype_title),
        nrOfOffers: this.controllerFor("queryData").get("nrOfOffers"),
        deal: this.controllerFor("queryData").get("deal"),
        price: this.controllerFor("queryData").get("price"),
        surface: this.controllerFor("queryData").get("surface"),
    });
  }
});

All those .get('[variable name]') are variables inside QueryData controller.

Update: added controller

App.QueryDataController = Ember.ObjectController.extend({
  id: null,
  property: null,
  deal: null,
  nrOfOffers: null,
  price: null,
  surface: null,

actions: {
    checkPropType: function (county, property, dealtype) {
        if(property.title ==="Apartment"){
                this.send('populateEstateData', property.title, dealtype.title, county.nrOfApartSale,county.avgPriceApartSale, county.avgSurfaceApartSale);
        }else if(property.title ==="House"){
                this.send('populateEstateData', property.title, dealtype.title, county.nrOfHouseSale,county.avgPriceHouseSale, county.avgSurfaceHouseSale);
        };  
    },

    populateEstateData: function(pProperty, pDeal,pNrOfOffers, pPrice, pSurface){
        this.set('id', 1);
        this.set('property', pProperty);
        this.set('deal', pDeal);
        this.set('nrOfOffers', pNrOfOffers);
        this.set('price', pPrice);
        this.set('surface', pSurface); 
    }},

PROBLEM: After page refresh I lose those variables ofcourse because they are declared as null again inside the controller.

QUESTION: How can I not reset the variables inside the contorller after page refresh so that I can load them again from Route.

来源:https://stackoverflow.com/questions/28833032/ember-js-controller-variables-reseting-after-page-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!