CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   JQuery Mobile sending me crazy (http://www.codingforums.com/showthread.php?t=241711)

defender110 10-22-2011 01:18 PM

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>


defender110 10-22-2011 04:19 PM

Hi,

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

hdewantara 10-23-2011 10:53 AM

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


All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.