Thursday 15 September 2011

jquery - Select2 fire event on mouseenter of results -


I have to reset a timer that closes the minor DIV in which there is a select2-container on the mouseover.

This is not a fire:

  $ ('select2-dropdown'). ('Mousecenter', function (e) {console.log ('in'); clear interval ($ (this) .data ('timer'));};  

I tried all possible selectors on the Dome but it is not a fire.

Thank you!

You do not set this handler correctly.

The dropdown only chooses when it chooses, and it is removed after closing. So you can not set up the handler once and forget about it, as long as you do not use event deletion.

  $ ('body'). ('Mousecenter', '.select2-results__option', function (e) {console.log ('in'); clear interval ($ (this) .data ('timer')););  

Then it will actually catch the event on body and then check that it came from the options of the results.

The second option is to keep your current handler, but instead of select2: open (on select) instead of ready Bind it. select2: close . During

it may be also need to attach it.

No comments:

Post a Comment