javascript - Backbone View not initializing -
i absolute beginner backbone js , have been trying follow along lines of this git repo. below bare minimum code have set in.
(function() { var mwlivepreview = {}; window.mwlivepreview = mwlivepreview; var mwtemplate = function(name) { homecoming _.template($("#" + name + "-template").html()); } var log = function(logit) { console.log(logit); } mwlivepreview.index = backbone.view.extend({ template: mwtemplate('live-preview'), render: function() { log(this.template(this)); this.$el.html(this.template(this)); homecoming this; } }); mwlivepreview.router = backbone.router.extend({ initialize: function(options) { this.el = options.el }, routes: { "": "index" }, index: function() { var view = new mwlivepreview.index(); this.el.empty(); this.el.append(view.render().el); } }); mwlivepreview.boot = function(container) { container = $(container); var router = new mwlivepreview.router({el: container}); backbone.history.start(); } })()
code below template have:
<script type="text/template" id="live-preview-template"> <div> have got few templates</div> </script>
and wiring whole thing calling code below on document ready
mwlivepreview.boot($("#asapatterns"));
i not sure went wrong returns next error:
uncaught typeerror: object function (a){return new m(a)} has no method 'pick'
any ideas or clues on might going wrong?
edit 1:
removing backbone.history.start()
stops giving error 1 time again nil comes in view.
from http://backbonejs.org/
backbone's hard dependency either underscore.js or lo-dash.
but careful match version required backbone: @ time of writing, underscore.js 1.4.3 backbone 0.9.10
javascript jquery backbone.js underscore.js
No comments:
Post a Comment