RsD0p9BK
3/6/2017 - 5:42 AM

backbone__get_id.js

// Backbone Model Ids and on click events
var AppointmentView = Backbone.View.extend({
  getModel: function (e) {
    //you might want to consider using data attributes instead
    var modelId = $(e.currentTarget).attr('id'); 
    var model = this.storeItems.get(modelId);
  },
  // http://stackoverflow.com/questions/24703561/backbone-model-ids-and-on-click-events
  
  editPost: function(e) {
    e.preventDefault();
    var id = $(e.currentTarget).data("id");
    var item = this.collection.get(id);
  }
  // http://stackoverflow.com/questions/9563663/how-to-find-the-id-of-model-corresponding-to-clicked-item
});