javascript - Marionette.js - Uncaught ReferenceError: text is not defined -


i wonder if can find what's wrong in case. "uncaught referenceerror: text not defined" in line 6 app.js:

((__t=( text ))==null?'':_.escape(__t))+ 

driver.js:

var marionette = require('backbone.marionette'); var todoview = require('./views/layout');  var initialdata = {   items: [     {assignee: 'scott', text: 'write book marionette'},     {assignee: 'andrew', text: 'do coding'}   ] };   var app = new marionette.application({   onstart: function(options) {     var todo = new todoview({       collection: new backbone.collection(options.initialdata.items),       model: new todomodel()     });     todo.render();     todo.triggermethod('show');   } });  app.start({initialdata: initialdata}); 

views/layout.js

var backbone = require('backbone'); var marionette = require('backbone.marionette'); var todomodel = require('../models/todo');  var formview = require('./form'); var listview = require('./list');   var layout = marionette.view.extend({   el: '#app-hook',    template: require('../templates/layout.html'),    regions: {     form: '.form',     list: '.list'   },    collectionevents: {     add: 'itemadded'   },    onshow: function() {     var formview = new formview({model: this.model});     var listview = new listview({collection: this.collection});      this.showchildview('form', formview);     this.showchildview('list', listview);   },    onchildviewaddtodoitem: function(child) {     this.model.set({       assignee: child.ui.assignee.val(),       text: child.ui.text.val()     }, {validate: true});      var items = this.model.pick('assignee', 'text');     this.collection.add(items);   },    itemadded: function() {     this.model.set({       assignee: '',       text: ''     });   } });  module.exports = layout; 

todoitem.html

<%- item.text %> &mdash; <%- item.assignee %> 

any can me explain why text not defined?

you should take @ marionnette's itemview documentation explain how render template custom data.

var my_template_html = '<div><%= args.name %></div>' var myview = marionette.itemview.extend({   template : function(serialized_model) {     var name = serialized_model.name;     return _.template(my_template_html)({         name : name,         some_custom_attribute : some_custom_key     });   } });  new myview().render(); 

note using template function allows passing custom arguments .template function , allows more control on how .template function called.

with code provided @ moment, can't help.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -