Can anybody give a small example about how to load a new div container based on a mouse click, using Backbone.js? I would like to add a new div container to my already existing html contents.
Asked
Active
Viewed 2,863 times
1 Answers
5
In a view class:
events: { "click #myButton": "insertDiv" }
insertDiv: function(event) {
this.$el.append("<div>...</div>");
}

Tanzeeb Khalili
- 7,324
- 2
- 23
- 27
-
How to append a div with a particulr id, say; div_id, which is already defined in an html file? – JeanFrancois Jul 27 '12 at 12:40
-
Try `this.$el.append( $("#div_id").html() )` – Tanzeeb Khalili Jul 27 '12 at 15:56