May 2017
Beginner to intermediate
536 pages
14h 25m
English
Backbone.js allows you to define events on each view, making it possible to restrict the scattering of events. This technique allows developers to quickly understand the events used for any given screen without having to search through all the code. Here, we need two events to display the topic creation form and submit the data to the server. Let's add the following code to the TopicListView variable created previously:
events: { 'click #wpwaf_add_topic': 'addNewTopic', 'click #wpwaf_topic_create': 'saveNewTopic' }, addNewTopic: function(event) { $("#wpwaf_topic_add_panel").show(); }
As you can see, all the events are separated into a section called events inside the view. We have used a click ...
Read now
Unlock full access