JQuery MouseLeave Function

Hi,

I'm trying to add a Mini Basket Preview to my site, easier said than done. I have 2 divs, one shows the basket summary and then another hidden one drops down with the preview when you hoiver over the summary, its then suppossed to stay there whilst you are in either and move back up after 3-4 seconds when you leave both. Could somebody advise on the below.

$(function () {

    var timeout;
    $(".col4").hoverIntent(function () {
        $("#ddContent").slideDown(800);
        clearTimeout(timeout);
    });

    $("#ddContent").hoverIntent(function () {
         $("#ddContent").slideDown(800);
        clearTimeout(timeout);
    });

    $("#ddContent,.col4").stop().mouseleave(function () {
        timeout = setTimeout(function () {
            $("#ddContent").slideUp(800);
        }, 2000);
    });
});

Open in new window

Karl BlackburnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
you did not post your HTML.
the issue is most of time due to the HTML, for example when you decide to put child outside parent, I mean the dropdown and its items
0
Karl BlackburnAuthor Commented:
Slight change. I know have

<div id="basketholder">
<div id="col4" class="col4" style="overflow:visible">

<asp:UpdatePanel runat="server">
<contenttemplate>
<div class="baskettitle"><asp:HyperLink ID="LblBasketTitle" runat="server" NavigateUrl="basket.aspx">My Basket</asp:HyperLink></div>
<div class="basketcontent"><asp:HyperLink ID="LabelBasket" runat="server" NavigateUrl="basket.aspx"></asp:HyperLink></div>
</contenttemplate>
</asp:UpdatePanel>

<div style="position:relative;height:1px">
<img id="shoppingdot" src="images/siteassets/standard/shoppingbasketbutton.png" style="position:absolute;top:74px; right:80px;z-index:10001" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="DivBasketAdd" class="minibasket">
<asp:Literal ID="LtlMiniAdd" runat="server"></asp:Literal>
</div>
<div id="ddContent" class="minibasket">
<asp:Literal ID="LtlMiniCart" runat="server"></asp:Literal>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>

</div>
</div>

Open in new window


$(function () {

    var timeout;
    $("#basketholder,#LblBasketTitle,#LabelBasket,#ddContent, #shoppingdot").hoverIntent(function () {
        $("#ddContent").slideDown(800);
        clearTimeout(timeout);
    });

    $("#basketholder,#ddContent,#col4").stop().mouseleave(function () {
        setTimeout(function () {
            $("#ddContent").delay(500).slideUp(1200);
        }, 2000);
    });
});

Open in new window

0
RobOwner (Aidellio)Commented:
Given it's more a javascript question that asp, would you mind posting the rendered html rather than the asp markup please?
Load the page in the browser, right click, view source and copy and paste that.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Karl BlackburnAuthor Commented:
See below

<div id="basketholder">
<div id="col4" class="col4" style="overflow:visible">

<div id="ctl00_ctl10">
	
<div class="baskettitle"><a id="ctl00_LblBasketTitle" href="basket.aspx">My Basket</a></div>
<div class="basketcontent"><a id="ctl00_LabelBasket" href="basket.aspx">22 items<br>£243.42</a></div>

</div>

<div style="position:relative;height:1px">
<img id="shoppingdot" src="images/siteassets/standard/shoppingbasketbutton.png" style="position:absolute;top:74px; right:80px;z-index:10001" />
<div id="ctl00_UpdatePanel1">
	
<div id="DivBasketAdd" class="minibasket">

</div>
<div id="ddContent" class="minibasket">
<div class="minibasketinner"><div class="header">BASKET PREVIEW</div><table style="width:96%; margin-left:6px" cellpadding="4"><tr><td><a href="details.aspx?PID=8205"><img src="http://www.metoyouonline.com/images/product1/G01W1546.jpg" width="60px" /></a></td><td style="text-align:left"><a href="details.aspx?PID=8205">2 x 4" Silver Wedding Anniversary Me to You Bear   <br>Qty : 18</a></td><td>£233.82</td></tr><table style="width:96%; margin-left:6px" cellpadding="4"><tr><td><a href="details.aspx?PID=9300"><img src="http://www.metoyouonline.com/images/product1/A77TS040.jpg" width="60px" /></a></td><td style="text-align:left"><a href="details.aspx?PID=9300">Wife Anniversary Me to You Bear Card  <br>Qty : 4</a></td><td>£9.60</td></tr><tr><td colspan="3" style="height:20px; border-top:2px solid #9ed6f5; text-align:right; color:#de006e; font-weight:bold">TOTAL : £243.42</td></tr><tr><td colspan="3"><a href="basket.aspx"><img src="images/siteassets/minibasket_viewbasket.jpg" width="110" height="25"></a><a href="basketoffers.aspx"><img src="images/siteassets/minibasket_checkout.jpg" width="118" height="25"></a></td></tr></table></div>
</div>

</div>
</div>

</div>
</div>

Open in new window


Many thanks
0
RobOwner (Aidellio)Commented:
I think it's this simple: http://jsbin.com/yiwife/2/edit

$(function () {

	var timeout;
	$("#ctl00_ctl10").hoverIntent(
		function() {
			$("#ddContent").delay(500).slideUp(1200);
		},
		function() {
			$("#ddContent").delay(500).slideDown(800);
		}
	);
});

Open in new window

0
Karl BlackburnAuthor Commented:
Hi,

Apologies, that doesn't seem to work, the idea being as long as you enter or stay within one of the divs the scroll stays down, the div ctl00_ctl10 is onyl wrapped around the wording, when you leave all of them it then waits a couple of seconds and scrolls back up. When I tried this version it went up and down a few times when hovering over the open slider.

Cheers
Karl
0
RobOwner (Aidellio)Commented:
No need to apologise!  I just thought that you wanted the animation to happen when hovering over the words..

So I need to understand exactly what you want to happen when.  So what element do you want to trigger the preview?
0
Karl BlackburnAuthor Commented:
Basically any element within basketholder and then whilst hovering over the ddcontent area, once you leave any of those completely it should slide back up.
0
RobOwner (Aidellio)Commented:
Which the following code should do, but what you're showing needs to be in "#basketholder" as well.  What's the element you're showing called?

$(function () {

	var timeout;
	$("#basketholder").hoverIntent(
		function() {
			$("#ddContent").delay(500).slideUp(1200);
		},
		function() {
			$("#ddContent").delay(500).slideDown(800);
		}
	);
});

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karl BlackburnAuthor Commented:
Hi,

Apologies for the delayed reply.

I still havent had much luck using the above, new ideas from me or looking at articles.

The HTML :

<div id="col4" class="col4" style="overflow:visible">
<div id="ctl00_ctl10">
	
<div class="baskettitle"><a id="ctl00_LblBasketTitle" href="basket.aspx">My Basket</a></div>
<div class="basketcontent"><a id="ctl00_LabelBasket" href="basket.aspx">22 items<br>£243.42</a></div>

</div>

<div style="position:relative;height:1px">
<img id="shoppingdot" src="images/siteassets/standard/shoppingbasketbutton.png" style="position:absolute;top:74px; right:80px;z-index:10001" />

<div id="ddContent" class="minibasket">
<div class="minibasketinner"><div class="header">BASKET PREVIEW</div><table style="width:268px; margin-left:6px" cellpadding="4"><tr><td><a href="details.aspx?PID=8205"><img src="http://www.metoyouonline.com/images/product1/G01W1546.jpg" width="60px" /></a></td><td style="text-align:left"><a href="details.aspx?PID=8205">2 x 4" Silver Wedding Anniversary Me to You Bear   <br>Qty : 18</a></td><td>£233.82</td></tr><tr><td style="text-align:center" colspan="3"><img src="images/siteassets/minibasket_break.jpg" /></td></tr><tr><td><a href="details.aspx?PID=9300"><img src="http://www.metoyouonline.com/images/product1/A77TS040.jpg" width="60px" /></a></td><td style="text-align:left"><a href="details.aspx?PID=9300">Wife Anniversary Me to You Bear Card  <br>Qty : 4</a></td><td>£9.60</td></tr><tr><td colspan="3" style="border-top:2px solid #9ed6f5; text-align:right; color:#de006e; font-weight:bold; font-size:13px; padding-top:7px">TOTAL : £243.42</td></tr><tr><td colspan="3"><a href="basket.aspx"><img src="images/siteassets/minibasket_viewbasket.jpg" width="125"></a><img src="images/siteassets/minibasket_button_spacer.jpg" width="6px" height="25px"><a href="basketoffers.aspx"><img src="images/siteassets/minibasket_checkout.jpg" width="125"></a></td></tr></table></div>
</div>

</div>
</div>

Open in new window


I have div col4 wrapping around everything, this holds the basket image slice, total etc and then within this is ddContent, this is a dynamically generated area of the baskets contents.

The issue is using the javascript

$(function () {

    var timeout;
    $(".col4").hoverIntent(function () {
        $("#ddContent").slideDown(200);
        clearTimeout(timeout);
    });

    $("#ddContent").hoverIntent(function () {
        $("#ddContent").slideDown(200);
        clearTimeout(timeout);
    });

    $(".col4,#ddContent").stop().mouseleave(function () {
        timeout = setTimeout(function () {
            $("#ddContent").slideUp(800);
        }, 2000);
    });

Open in new window


or a variety other similiar jquery codes it either

- locks open when i move outside
- goes up and down like a yoyo
- closes when i'm hovering the #ddContent

Any help would be much appreciated?

Cheers
Karl
0
RobOwner (Aidellio)Commented:
Hi Karl,

I'm still missing something.. There's nothing to show as far as I can see...

Why are you wanting the slideDown to happen?  What is shown when this happens?

This is a simplified demo: http://jsbin.com/tagica/1/edit?html,css,js,output

How different do you need it to that?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.