The "el" property references the DOM object created in the browser. Every Backbone.js view has an "el" property, and if it not defined, Backbone.js will construct its own, which is an empty div element.
Let us set our view's "el" property to div#search_container, effectively making Backbone.View the owner of the DOM element.
<div id="search_container"></div>

<script type="text/javascript">
    SearchView = Backbone.View.extend({
        initialize: function(){
            alert("Alerts suck.");
        }
    });
    
    var search_view = new SearchView({ el: $("#search_container") });
</script>

0 comments :

Post a Comment

 
Top