I have some custom javascript tied to a link in add to cart form that has been added with hook_form_alter. On a click, all it does is retrieve some information and populate a text field. This works fine. It is added with a normal drupal_add_js call.

However, with uc_aac enabled and on a product with just a single attribute, it's like the click event on the link is never registered. Nothing happens. Even though none of the DOM has changed. It's like it stops some javascript from running. Other custom javascript is working fine, except this one click even on the link.

Any nods in the right direction would be appreciated. Thanks!

Comments

TravisJohnston’s picture

This is an old post, but I just experienced this. I was trying to setup a function that will show/hide attributes depending on which other attributes you clicked. Works fine with AAC turned off, but when its on, AAC take priority and stops all other functions outside of it from working. In the console, i can get it to work "kinda" but thats about it.

TravisJohnston’s picture

This is really bothering me. I tried changing the weight of the module in my DB but that didn't work. I can't use any JS on the form elements when this module is activated. What gives?

TravisJohnston’s picture

Priority: Normal » Critical
deaftone’s picture

I'm having the same issue. Custom jQuery is not working with AAC enabled. I need this functionality. How to fix this?

TravisJohnston’s picture

Hello @deaftone,

I managed to find someone that created a patch for it in there new module. http://drupal.org/project/uc_conditional_attributes

I can't find the original conversation but it took place on the uc_cano module forums. He not only created the conditional attribute module, but he also provides a patch to fix the way AAC reacts to other JS.

*Edit, just found the original conversation. http://www.ubercart.org/project/uc_cano?page=3

deaftone’s picture

Hello Travis,

I will give this patch a try,

Thanks a lot.

deaftone’s picture

The patch right here http://www.ubercart.org/project/uc_cano?page=3#comment-64313 does not work. Still the same result, and I've got weird numbers in text boxes.

RAWDESK’s picture

Issue summary: View changes

Hello all,
I believe i am experiencing a similar symptom using the UC product attributes ajax api.
Only in my case it is not breaking a specific JS function, but influencing its (calculation) behaviour.
For some reason the incremental parameter for the add to cart amount (which is 1), gets increased by 1 on every aac event.

You can witness the symptom in this screencap :
http://castabo.rawdesk.be/temp/uc-product-attribute-event-bug.flv

Html source snippet containing the [-] amount [+] section :

<div class="quantity">
<a href="#" title="remove from cart" class="ac-button minus">-</a>
<div class="form-item form-type-uc-quantity form-item-qty">
  <input class="qty text input-text form-text required" type="text" id="edit-qty" name="qty" value="1" size="5" maxlength="6" />
</div>
<a href="#" title="add to cart" class="ac-button plus">+</a></div>
<input type="hidden" name="form_build_id" value="form-oUks1xxIpcGHlIPd9IOEzwvglFsUFoHXff9zvdnCz7U" />
<input type="hidden" name="form_id" value="uc_product_add_to_cart_form_319" />

Someone already found the cause for this JS interference ?

Thanks

RAWDESK’s picture

Solved my issue following this thread :
https://www.drupal.org/node/1255306
using the once() qualifier to force the handler only to be triggered once

	Drupal.behaviors.acShoppingCard = {
		attach: function (t, n) {
			$('.quantity a', t).once().on('click', function(e){
				e.preventDefault();
				$qty = $(this).closest('.quantity').find('input.qty');
				$qty_val = parseInt($qty.val());
				if ($(this).is('.plus')) {
					$qty.val($qty_val+1);
				}else if ($qty_val>1){
					$qty.val($qty_val-1);
				}
			});
		}
	};