Zseven Zseven - 4 months ago 14
jQuery Question

jquery in ajax.load loader showing every "mouseover"

i hope subject is clear, i try to explain better my problem.

I have a menu and i'd like to load submenu just on mouseover on parent li of menu.
It works, but every time i go on parent, i see loader.
I'd like that loader to be visible just on first mouseover.
You can see it here:
http://v2.profumee.com

Thanks in advance.

This is the code:

function pageLoad() {

var SessionLingua = '<%= Session("Lingua") %>';

$(".LinkPadreBoxMenu").mouseover(function (event) {
event.preventDefault(); //preventing button's default behavior
var IDCategoriaGenitore = $(this).next("#LblIDCategoria").html();

$('.A_' + IDCategoriaGenitore).show();

$(".SottoCategorieAjax_" + IDCategoriaGenitore).load('/' + SessionLingua + '/ajax_categorie.aspx', { 'IDCategoriaGenitore': IDCategoriaGenitore }, function () {
$('.A_' + IDCategoriaGenitore).hide();
});
event.stopPropagation();
});

}

Answer Source

Use localStorage to store some value on ajax call. Now next time when you hover, check whether you have localstorage value. By this, you can condition you loading image.