Hello.
There is a view:
var SessionView = Backbone.View.extend({ el: $("#main_content"), template: JST["main"], render: function() { $(this.el).html(this.template); return this; } }); var view = new SessionView(); And the router:
var ProfileRouter = Backbone.Router.extend({ routes: { "main": "main" }, main: function(){ view.render(); } }); Eventually:
this.el is undefined , and thus the template is not rendered.
But if $ (this.el) .html (this.template); replace with $ ("# main_content"). html (this.template); - then everything works.
Tried to use this. $ El.html () - it is also not rendered, although the selector indicates the correct
Tell me please what am I doing wrong?
thiswhat does it indicate? Look, maybe you will find the problem - BOPOH$(document).ready? just other reasons why$("#main_content") - undefinednot visible. besidesthis.elyou already have a jQuery object so using$(this.el)redundant - Specter$("#main_content").html(this.template);works, it follows that during the callview.render();,#main_contentexists, but at runtimevar view = new SessionView();- no, becauseel: $("#main_content")returns undefined. what version of backbone do you use? - Specter