Passing parameters into the Backbone events object of a backbone view

后端 未结 4 581
梦谈多话
梦谈多话 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条回答
  •  萌比男神i
    2020-12-13 00:35

    You can do so using closures:

    EventObject.on(event, (function(){
        var arg = data; // Closure preserves this data
        return function(){
            doThis(arg);
        }   
    })());
    

提交回复
热议问题