Hi I was wondering how I handle the remove hover state using backbone and js
currently I have
events: {
"hover .info" : "hover"
},
hover:(e) =>
$(e.currentTarget).css("background-color", "#333")
I was wondering how I would handle the event where i move my mouse away from the element with class .info
If i do standard coffee script inside to do this inside the hover: event handler it requires 2 hovers for it to work.
I basically want to imitate
$(".info").hover(
function() {
$(this).css("background-color", "#333")
},
function() {
$(this).css("background-color", "#F3F")
},
});
Thanks
There is a version of
hover()that takes one callback function:This is the version of
hoverthat will get used by Backbone. So you could handle this withtoggleClassand a couple CSS classes instead of directly messing around with thecss:The default
#F3Fcolor would be set on the element by default and you’d have:in your stylesheets. If you cannot for some reason use
toggleClass, you’d have to bind tomouseenterandmouseleaveindividually.