简体   繁体   English

重启Backbone.View

[英]Restart Backbone.View

I have a Backbone View and I want restart it. 我有一个骨干网视图,我想重新启动它。 The view prints a table with prices but when the user push a check, the prices have that change. 该视图打印带有价格的表,但是当用户按下支票时,价格会发生变化。 I don't know restart my backbone View. 我不知道重新启动我的骨干网视图。

GrillaView = Backbone.View.extend({
    events : {
        // events
    },
    initialize : function(){
        // templates
    },
    render : function (){
        this.$el.removeClass('hidden');
        this.renderQuote();
    },
    setCategories : function (collection){
        // Print a template
    },
    addResult : function (item){
        // Print other template
    },
    setPrice : function (prov,item){
        // prices
    },
    filterFuel : function(e){
        // Here I need restart the View
    }

Totally unclear question but I assume you want to rerender when new data are available. 完全不清楚的问题,但我想您想在有新数据时重新显示。 So when new data are here you'll trigger this.render(); 因此,当有新数据时,您将触发this.render();。 inside your view. 在您的视图中。

the render function should get its data from a model, when the model is updated you trigger render(). 渲染函数应该从模型获取数据,更新模型时,您将触发render()。 It's that simple. 就这么简单。 But without more code it's hard to tell what's your problem. 但是,如果没有更多代码,很难说出您的问题所在。

let me know if it helps. 让我知道是否有帮助。

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

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