Hello,
I am working with the accordion widget for a menu.
A list of submenu items have open on hover with accordion.
The problem is that on load, the first item is always open.
How can I make it be closed?
So when I load my page and access, I cannot see the inside content until I hover over the items.
This is my code:
(btw, I need to use the Jquery no cnflict because I am using a CMS that requires it)
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript">
jQuery.noConflict();
jQuery(function() {
jQuery( "#accordion" ).accordion({
event: "click hoverintent"
});
});
/*
* hoverIntent | Copyright 2011 Brian Cherne
* modified by the jQuery UI team
*/
jQuery.event.special.hoverintent = {
setup: function() {
jQuery( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler );
},
teardown: function() {
jQuery( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler );
},
handler: function( event ) {
var currentX, currentY, timeout,
args = arguments,
target = jQuery( event.target ),
previousX = event.pageX,
previousY = event.pageY;
function track( event ) {
currentX = event.pageX;
currentY = event.pageY;
};
function clear() {
target
.unbind( "mousemove", track )
.unbind( "mouseout", clear );
clearTimeout( timeout );
}
function handler() {
var prop,
orig = event;
if ( ( Math.abs( previousX - currentX ) +
Math.abs( previousY - currentY ) ) < 7 ) {
clear();
event = jQuery.Event( "hoverintent" );
for ( prop in orig ) {
if ( !( prop in event ) ) {
event[ prop ] = orig[ prop ];
}
}
// Prevent accessing the original event since the new event
// is fired asynchronously and the old event is no longer
// usable (#6028)
delete event.originalEvent;
target.trigger( event );
} else {
previousX = currentX;
previousY = currentY;
timeout = setTimeout( handler, 100 );
}
}
timeout = setTimeout( handler, 100 );
target.bind({
mousemove: track,
mouseout: clear
});
}
};
</script>
Thank you!
Best regards
Paula Colchero