JeanFrancois
JeanFrancois

Reputation: 134

How can i append a view to existing html markup using backbone.js

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.

Upvotes: 0

Views: 2866

Answers (1)

Tanzeeb Khalili
Tanzeeb Khalili

Reputation: 7344

In a view class:

events: { "click #myButton": "insertDiv" }

insertDiv: function(event) {
    this.$el.append("<div>...</div>");
}

Upvotes: 5

Related Questions