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

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -