backbone.js - HandleBars Compile w/ RequireJS and BackboneJS -


requirejs configuration:

require.config({     baseurl: '/js/',     paths: {         jquery: './libs/jquery/jquery-1.10.1.min',         underscore: './libs/underscore/underscore-min',         backbone: './libs/backbone/backbone-min',         handlebars: './libs/handlebars/handlebars',         templates: '/templates'     },      shim: {         underscore: {             exports: '_'         },          backbone: {             deps: ['jquery', 'underscore'],             exports: 'backbone'         }     } }); 

view:

define([   'backbone',   'handlebars',   'text!templates/mytemplate.html' ], function(backbone, handlebars, template){      myview = backbone.view.extend({         tagname: 'li',         template: handlebars.compile(template),          render: function() {             this.$el.html(this.template(this.model.tojson()));             return this;         }     });      return myview; }); 

i encountered following error:

uncaught typeerror: cannot call method 'compile' of undefined. 

add shim configuration:

shim: {   handlebars: {     exports: 'handlebars'   }, 

Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -