KeenUser
KeenUser

Reputation: 5525

Use of hover throws up jquery-migrate error (jquery 1.9)

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

Upvotes: 0

Views: 892

Answers (2)

Barry Meijer
Barry Meijer

Reputation: 760

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."

Upvotes: 0

anderssonola
anderssonola

Reputation: 2195

.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

Upvotes: 1

Related Questions