How to find the Id of model corresponding to clicked item?

前端 未结 2 757
青春惊慌失措
青春惊慌失措 2021-01-13 08:04

How to know the Id of item I clicked? my code is given below:

$(function() {
  ipl.mvc.view.openings_view = ipl.mvc.vi         


        
2条回答
  •  孤独总比滥情好
    2021-01-13 08:45

    This is another (newer versions of backbone?) way of doing this: (I see @Sander shows the model.get method in his remarks)

    var AppointmentView = Backbone.View.extend({
      events: {
        'click' : 'alertTitle'
      },
    
      alertTitle : function(e) {
        // this.model.get('id') is what you're looking for
        alert( this.model.get('title') );
      }
    });
    

提交回复
热议问题