jQuery: receive extraParameters from triggerHandler()

4.3k Views Asked by At
   $('<span>test</span>')
    .change(function(e){console.log(e.data);})
    .triggerHandler('change',{foobar:1});

I'm doing it wrong or it's bugged?

Thanks ;)

1

There are 1 best solutions below

0
On BEST ANSWER

The extra data is passed as argument to the handler:

$('<span>test</span>')
.change(function(e, data){console.log(data);})
.triggerHandler('change',{foobar:1});

The documentation also says that it has to be an array, though it works with one object too.