0

I have a problem with getting this pop-up jquery: http://www.htmldrive.net/items/show/431/jQueryNotice-animated-notification-tooltip script to work in a shop which is coded in asp.net. When a product is added to the basket, I would like to have a pop up that allows you to go to the checkout by click - go to basket. Below you se the script, now I can click to go to the basket, where the product is added, but If I do not click, the product will not show in the basket - as it should ... - I have been told that it is a 'post back' problem ... does anyone have an idea how I solve the problem.? - I have previously asked about this problem - see also: Link in the message of jQnotice - i hope somone can/will help ;0)

    $(document).ready(function() {     
$('a.buy').click(function() {         
jQnotice('Message..!<a href="' + $(this).attr('href') + '">Go to shop</a>');         
return false;     }); }); 

html btn:

<span class="buy"><a href="/order/cart/add/productnr.." id="buy" class="buy">Add to basket</a></span>

If there are some who have another simple solution for this problem, please tell

Community
  • 1
  • 1
Pete
  • 5
  • 3
  • Is this a ASP.NET MVC? As I'm understand a link serves not for navigating to basked but rather for adding chosen item to it. Is it right? – Yuriy Rozhovetskiy Jul 17 '11 at 20:46
  • Hi, When you click on the "Go to shop", the product must be added to the users cart, and the user should be able to choose to go to the check out - or buy more ... it works great without pop up, but when I use the pop-up script, the product will not be added to the basket. I think it is asp.net MC – Pete Jul 17 '11 at 21:27
  • Try to remove return false; string from anchor's click event handler. Be warned that it's highly possible that if user will click an "Add to basket" link and then click "Go to shop" link item would be added twice. – Yuriy Rozhovetskiy Jul 17 '11 at 21:31
  • As an alternative you might perform an ajax call inside anchor's click handler right before jQnotice finction call: $.get($(this).attr('href')); – Yuriy Rozhovetskiy Jul 17 '11 at 21:43
  • If I do so, the pop up window doesn't show correctly .. it disappears quickly and the "go to the shop" link does not work .. however the product are added to the basket – Pete Jul 17 '11 at 21:44
  • you can make an example? – Pete Jul 17 '11 at 21:45
  • $(function() { $('a.buy').click(function() { $.get($(this).attr('href')); jQnotice('Message..!Go to shop'); return false; }); }); – Yuriy Rozhovetskiy Jul 17 '11 at 21:49
  • it almost seems to be working, the window/basket is just not updated, is there a way to fix that? – Pete Jul 17 '11 at 21:54

1 Answers1

0

Use this:

$(function () {
        $("a.buy").click(function () {
            $.get($(this).attr("href"),
            function (data) {
                var newBasket = $("#basket", data);
                $("#basket").html(newBasket.html());
            });
            jQnotice('Message..!<a href="' + $(this).attr('href') + '">Go to shop</a>');
            return false;
        });
    });

I make few assumptions here: the first one is that ajax call will return html with updated basket markup an that basket element has id 'basket'. Once again, be warned that if user will click link in popup message the same action will be executed once again so maybe better to change "Go to shop" link's href from add new product action to just navigating to basket review page.

Yuriy Rozhovetskiy
  • 22,270
  • 4
  • 37
  • 68