Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
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
Old 10-22-2011, 04:19 PM   PM User | #2
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
Hi,

Maybe it would be simpler to ask how I can disable Mobile JQuery Only in DIV tags and leave other ajax running.
defender110 is offline   Reply With Quote
Old 10-23-2011, 10:53 AM   PM User | #3
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 289
Thanks: 5
Thanked 40 Times in 40 Posts
hdewantara is an unknown quantity at this point
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
hdewantara is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:18 AM.


Advertisement
Log in to turn off these ads.