Your problem is because you’re not waiting for the DOM to be ready, try moving the div like this (http://jsfiddle.net/icodeforlove/68gGS/)
<body>
<div class="container"></div>
<script type="text/javascript">
var SearchView = Backbone.View.extend({
el: '.container',
initialize: function() {
this.render();
},
render: function() {
$(this.el).html("hello"); //tried both but not working.
this.$el.html("hello");
}
});
var search_view = new SearchView();
</script>
</body>
1
solved Backbone code not rendering simple View [closed]