Passing parameters into the Backbone events object of a backbone view

后端 未结 4 579
梦谈多话
梦谈多话 2020-12-13 00:06

I have the following events for a Backbone View. Its a product view - with three tabs (\"All\", \"Top 3\", \"Top 5\")

Can I somehow pass a parameter into the method

4条回答
  •  一整个雨季
    2020-12-13 00:24

    What you can do, is just check the id of the element which is received as currentTarget in arguments.

    topProduct: function (e) {
        var id = e.currentTarget.id;
        if (id == "top-all") // Do something
        else if (id == "top-5") // Do something
        else if (id == "top-3") // Do something
    }
    

提交回复
热议问题