title: Backbone.js - Liking a post, code refactoring
body: <p>Right now I'm using this code to Like a post. <strong>I'm Using jQuery methods to change the Like to Unlike and to change the Like count</strong></p>
  
  <p>View</p>
  
  <pre><code>Streaming.Views.StreamsIndex = Backbone.View.extend({
    events: {
      'click .like-icon': 'post_liked',
    },
  
    initialize: function(){
      this.model = new Streaming.Models.StreamsIndex();
      this.model.bind('post_likeSuccess', this.post_likeSuccess);
    },
  
    post_liked: function(event) {
      event.preventDefault();
      event.stopPropagation();
      current_target = $(event.currentTarget);
      liked_id = current_target.attr("id");
      href = current_target.attr('href');
      this.model.like(href, liked_id); // calls model to send API call for Like
    },
  
    post_likeSuccess: function(data, liked_id) {
      $("#" + liked_id).attr({
          "href": data.unlike,
          "title": "Unlike",
          "rel": "Unlike",
          "class": "likehead-ico_active" // changing like icon
      });
      //changing like count 
      $("#"+ liked_id+"_count").text(parseInt($("#"+ liked_id+"_count").text()) + 1);
    }
  });
  </code></pre>
  
  <p>Model: </p>
  
  <pre><code>Streaming.Models.StreamsIndex = Backbone.Model.extend({
    like: function(href, liked_id) {
      var self = this;
      $.ajax({
          url: href,
          type: "POST",
          dataType: "json",
          async: false,
          success: function (data) {
              self.trigger('post_likeSuccess', data, liked_id);
          },
          error: function (data) {
              self.trigger('post_likeFail', data, liked_id);
              alert("This action was not performed");
          }
      });
    }
  });
  </code></pre>
  
  <ol>
  <li>Is there a better way I can do this?   </li>
  <li>After liking a post can I change the Like text to unLike, Change the like count in a better way without using jquery?</li>
  </ol>