VM 3.0.18. chrome browser Version 54.0.2840.99 m
file > vmprices.js
Adding a <span> inside a button stop the button to work.
eg:
echo '<button type="submit" name="addtocart" class="addtocart-button" title="'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'"><span class="visible-phone"><i class="icon-shopping-cart"></i> <i class="icon-plus"></i></span><span class="hidden-phone">'.vmText::_( 'COM_VIRTUEMART_CART_ADD_TO' ).'</span></button>';
WHen you click in the <span> element this fails:
if (jQuery(targ).prop("type") == "submit" || jQuery(targ).prop("type") == "image" ) {
Virtuemart.sendtocart(e.data.cart);
return false;
}
I think if you know a little how it work "targ" is no anymore the submit button but the span inside. so prop type, do not exist !
I fixed this on removing this code.
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
But because this is a jquery element, i dont know why this code is here ?
And why checking for this type ? We have already a selector for addtocart button.
If i check on the debuger this lines :
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
e.target is the right target(the button) so the Safari bug fix break if you need to add an icon or a span inside the button in chrome browser and perhaps other borwsers.
Note:
using
Virtuemart.addtocart = function (e){
e.preventDefault();
Virtuemart.sendtocart(e.data.cart);
return false;
};
works for me
I think it is actually enough to remove
if (jQuery(targ).prop("type") == "submit" || jQuery(targ).prop("type") == "image" ) {
or to add span here. I just wonder myself why it makes sense to check the dom type. It secures nothing, it just blocks anything which is not an image or submit. Please try this way
Virtuemart.addtocart = function (e){
var targ;
if (!e) e = window.event;
e.preventDefault();
if(!Virtuemart.quantityErrorAlert(e)){
return false;
}
if(e.hasOwnProperty('stopSendtocart') && e.stopSendtocart == true){
return false;
}
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
Virtuemart.sendtocart(e.data.cart);
return false;
};
http://dev.virtuemart.net/attachments/download/1034/com_virtuemart.3.0.18.5_extract_first.zip