0

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 
makeitmorehuman
  • 11,287
  • 3
  • 52
  • 76
  • 1
    What do you mean? Why don't you want to use the bind shown above? The "current" value isn't stored anywhere for you to retrieve other than inside the event handler. The data is stored in the event and is dynamic and only accessible when it is triggered. It's not like the event's `data` is stored somewhere when you call `.trigger` and then the `.bind` event accesses that. Technically, you could pass anything to `trigger`, like different data "types", and `bind` could check based on that. – Ian Nov 14 '12 at 16:02

1 Answers1

2

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()            
});
toxicate20
  • 5,270
  • 3
  • 26
  • 38