jquery click() not working on certain buttons -
i'm new jquery , stuck code. hoping can me understand why below functions aren't working:
$(function(){ console.log('document ready begin'); /*add cart frontpage*/ $('.featured_li a.ajax_add_to_cart_button').click(function(){ console.log('frontpage start'); var s = s_gi(s_account); s.linktrackvars='products,events'; s.linktrackevents=s.events='scadd'; s.products = ';' + $(this).parent().find('h5').text(); s.tl(this, 'o', s.events + ':' + s.pagename); console.log('frontpage request sent'); }); /*newsletter signup*/ $('input[name="submitnewsletter"]').click(function(){ console.log('newsletter start'); var s = s_gi(s_account); s.linktrackvars='events'; s.linktrackevents=s.events='event1'; s.tl(this, 'o', $(this).attr("name") + ':' + s.pagename); console.log('newsletter request sent') }); /*add cart overview pages*/ //virker, men uden product string $('#product_list > li a.ajax_add_to_cart_button').click(function(){ console.log('overview ready'); var s = s_gi(s_account); s.linktrackvars='products,events'; s.linktrackevents=s.events='scadd'; s.tl(this, 'o', s.events + ':' + s.pagename); console.log('overview request sent'); }); console.log('document ready end') });
(s object adobe sitecatalyst onclick tracking.)
now, code newsletter signup working. related 2 add cart code pieces. frontpage code piece add cart buttons located here. , overview code piece add cart buttons located here.
if i'm running code in firebug console, working expected. when running separate js file nothing happens. no matter can't execute of code wihtin add cart click function. tried place alert within without luck.
if change code apply click function info/view product button, working fine. on add cart button can't work.
any input appreciated i'm lost here.
thanks, kasper
update: believe i've found root cause. cart module prestashop has following code:
$('.ajax_add_to_cart_button').unbind('click').click(function(){ var idproduct = $(this).attr('rel').replace('nofollow', '').replace('ajax_id_product_', ''); if ($(this).attr('disabled') != 'disabled') ajaxcart.add(idproduct, null, false, this); return false; }); //for product page 'add' button... $('#add_to_cart input').unbind('click').click(function(){ ajaxcart.add( $('#product_page_product_id').val(), $('#idcombination').val(), true, null, $('#quantity_wanted').val(), null); return false; });
i guess unbind removing onclick i'm trying apply it, why button can't work on.
Comments
Post a Comment