Using Marionette.ItemView for views without models?

后端 未结 2 1712
长发绾君心
长发绾君心 2021-02-04 13:29

Is it conventional to use Marionette.ItemView for view classes that do not have a specific model property associated with them?

As Mario

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-04 13:36

    I just found out you can use a templateHelper for this - just chuck this in your ItemView declaration:

    templateHelpers: function() {
        return {
            message: this.message,
            cssClass: this.cssClass
        }
    }
    

    And then in your template:

    
    

    And then when you initialise the view:

    var noticeView = new App.Views.Notice();
    noticeView.message = "HELLO";
    App.noticeRegion.show(noticeView);
    

    I would be interested in your thoughts on this Derick?

提交回复
热议问题