我有以下代码:
bindEvents: function() {
$('#weight').click($.proxy(function(){
this.changeWeight($('#weight').is(':checked'));
},this));
$('#produce').change($.proxy(function(){
this.changeProduce();
},this));
$('.help-gtin').click($.proxy(function(){
if ($('#help-gtin').is(':hidden')) {
$('#help-gtin').slideDown();
} else {
$('#help-gtin').slideUp();
}
this.refreshGtin();
},this);
$('[name="order_production"]').click($.proxy(function(){
this.changeProduction();
},this));
},
如何减少此重复代码$.proxy 调用,因为内部的所有方法bindEvents
都需要在this
范围内调用?