I have a list of items dynamically rendered by knockout data binding. I need to bind the hoverIntent event with that instead of mouseover and mouseleave events.
<a data-bind="attr: { title: $data.Header, href: $root.GetUrl() }, event: { mouseover: function() { $root.showPopup($data.Id) }, mouseleave: function() { $root.hidePopup($data.Id) } }">
<span data-bind="html: $data.Header"></span> </a>
The functions are simply as follows;
self.showPopup = function(id) {
$("#popup-"+id).slideDown();
};
self.hidePopup = function(id) {
$("#popup-"+id).slideUp();
};
Please help. Thanks
Custom bindings is how you should do it. In this case a simple wrapper around
$().hoverIntentshould suffice.The binding above enables 2 of the hoverIntent parameter syntaxes:
.hoverIntent(handlerInOut)and.hoverIntent(optionsObject), for example:See it in action in a fiddle.