View Single Post
Old 10-22-2011, 01:18 PM   PM User | #1
defender110
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
defender110 is an unknown quantity at this point
Exclamation JQuery Mobile sending me crazy

Hi all,

I've applied JQuery Mobile to my Virtuemart site, now trying to edit.

My add to cart button should fire a Virtuemart AJAX function called handleAddToCart however JQuery Mobile AJAX linking disables this.

I need away to disable AJAX Mobile on the add to cart link AND run the original function handleAddToCart. I'm currently using preventDefault() which successfully prevents JQuery Mobile from doing a AJAX link but it also doesn't fire the original handleAddToCart function.

Spent hours on this, if anyone can see how to fix I will worship you!!

This JQuery successfully stops JQuery mobile from hijacking the link but it wont start handleAddToCart function!
Code:
<script>
$('[data-role="page"]').bind('pageinit', function () {
    $('.addtocart_form').bind('click', function (e) {
        e.preventDefault();
        //add your custom ajax call here
	
		$('.bsubmitcart').click(handleAddToCart);
    });
});
</script>
This is the button and form i'm trying to control. As you can see the onsubmit is already set to use handleAddToCart via a php echo:
Code:
<form action="<?php echo $mm_action_url ?>index.php" method="post" name="addtocart" id="addtocart<?php echo $i ?>" class="addtocart_form" <?php if( $this->get_cfg( 'useAjaxCartActions', 1 ) && !$notify ) { echo 'onsubmit="handleAddToCart( this.id );return false;"'; } ?>>
    <div class="bsubmitcart">	<input type="submit" id="addcartsubmit1" style="border:none;" class="<?php echo $button_cls ?>" value="Add to Cart" title="<?php echo $button_lbl ?>" /> </div>

Last edited by defender110; 10-22-2011 at 01:21 PM..
defender110 is offline   Reply With Quote