문제

If I have got:

blockRoutes = function (value) {
        $('body').trigger('cantLeaveRoute', { val: value });
        return value;
}

Except in binding callback like:

this.bind('cantLeaveRoute', function () {
        this.params['val'] === true ? nav.disableHeader() : nav.enableHeader()            
 });

How can I DIRECTLY (without the bind shown above) read the current value of the param?

Something along the lines of the wrong syntax below:

$('body').data('events')['cantLeaveRoute'].val 
도움이 되었습니까?

해결책

The parameters you set in trigger are part of the event

this.bind('cantLeaveRoute', function (event) {
 var value = event.data.val;
 value === true ? nav.disableHeader() : nav.enableHeader()            
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top