backbone.js - Is there a way to change Marionette ItemView template dynamically with RequireJS? -


I am trying to manipulate item views dynamically in the merchant collections. The archive is the same model, but I define template name logic inside the model.

The question is, can I manipulate the item view template with this argument?

Item view:

  Define (['text! Templates / ComponentItemViewTemplate.html', 'Model / ComponentModel'], Function (template, model) {var ItemView = Backbone.Marionette.ItemView.extend ({template: _.template) (template), model: model}); Item item; Return;};   

View collection:

  Define (['views / ComponentItemView', 'views / LoadingView'], function (item view, loading ) {Var ComponentListView = Backbone .Marionette.CollectionView.extend ({emptyView: loadingview, id: "component-list", item view: item view, events: {click on the title: 'show'}, append html: function (See collection, item view, index) {/ I would like to present different templates for different models. ItemView. $ El.draggable ({Helpful: "Clone", Cancellation : ".component .title span", connectToSortable: ".ui-sortable"}); collectionView $ El.append (itemView.el);}, show: function (r) {var target = $ (r.target) ; If (target.parent () .hackle ('open')) {target.parent (.removeClass ('open'); target.parent (). Next (). Slide down ('sharp');} and {Target.parent (). AddClass ('open'); target.parent (). Next () .slideUp ('fast');}}}); Return ComponentListView;});   

thanks

You can override the getTemplate function and You can write your own custom logic option below:

  MyView = Backbone.Mirienet.itviewview Extension ({getTemplate: function () (if (this.model.get ("foo")) {return "#some -metlet";} and {return "# different template";}}});    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -