Pregunta

Continuation to the question -replacement for hover() in jquery1.9?

if .hover() should still work fine with 1.9, I am seeing the below error in console to replace hover with mouseenter, mouseleave.

Code and error screenshot below

  this.handle=this.handles.eq(0);

this.handles.add(this.range).filter("a").click(function(c){c.preventDefault()}).hover(function(){a.disabled||d(this).addClass("ui-state-hover")}

enter image description here

¿Fue útil?

Solución

.hover() is still supported, it's the pseudo-event that has been removed.

For example

.bind( "hover", function() {})

should be replaced by

.bind( "mouseenter mouseleave", function() {})

ref: http://jquery.com/upgrade-guide/1.9/#quot-hover-quot-pseudo-event

Otros consejos

It's a little hard to answer this question because you already know what is deprecated and what not, in your question. But what you really want to know is, why is your code throwing a warning, when it -in the code- looks all OK.

So we have to figure out what is going on in your code. For example, what does this piece of code refer to? What is "onHover" in your code?

this.element.hover(this.options.onHover);

For reference: http://api.jquery.com/on/#additional-notes "Deprecated in jQuery 1.8, removed in 1.9: The name "hover" used as a shorthand for the string "mouseenter mouseleave". It attaches a single event handler for those two events, and the handler must examine event.type to determine whether the event is mouseenter or mouseleave. Do not confuse the "hover" pseudo-event-name with the .hover() method, which accepts one or two functions."

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top