Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Maybe it would be simpler to ask how I can disable Mobile JQuery Only in DIV tags and leave other ajax running.

  • #3
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    425
    Thanks
    10
    Thanked 62 Times in 61 Posts
    Does div.bsubmitcart binding to click event have to be inside the form.addtocart_form binding? Could it be moved out from red to blue, like below?
    Code:
    $('[data-role="page"]').bind('pageinit', function () {
      $('.addtocart_form').bind('click', function (e) {
        e.preventDefault();
        //...
        //$('.bsubmitcart').click(handleAddToCart);
      });
      $('.bsubmitcart').click(handleAddToCart);
      //...
    });
    Hendra


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •