Once the page load is completed, we need to fetch the topics from the server to be displayed on the profile page. So let's update the view with the necessary functions, as shown in the following code:
var TopicListView = Backbone.View.extend({ el: $('#forum_member_topics'), initialize: function () { topicsList = new TopicCollection(); topicsList.bind("change", _.bind(this.getData, this)); this.getData(); } getData: function () { var obj = this; topicsList.fetch({ success: function () { obj.render(); } }); }, });
Inside the initialize function, we bind an event named change for the topicsList collection, to call a function named getData. This event will get fired whenever we change the ...