Creating new models in the server

This is the final section of the process for saving new topics to database. Now, we have to implement the saveNewTopic function defined in the events section, as shown in the following code:

    saveNewTopic: function(event) {       var options = {         success: function (response) {           if("error" == response.changed.status){ }         },         error: function (model, error) {                               console.log(error);         }       };       var topic = new Topic();       var topic_title = $("#wpwaf_topic_title").val();       var topic_content = $("#wpwaf_topic_content").val();       var topic_forum = $("#wpwaf_topic_forum").val();       var forum_member_id = $("#wpwaf_topic_forum_member").val();       topicsList.add(topic);       topicsList.create({         topic_title: topic_title,  topic_content:topic_content, ...

Get Wordpress Web Application Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.