/[drupal]/contributions/modules/uc_aac/uc_aac.js
ViewVC logotype

Contents of /contributions/modules/uc_aac/uc_aac.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Nov 4 19:04:50 2009 UTC (3 weeks, 3 days ago) by antoinesolutions
Branch: MAIN
Branch point for: DRUPAL-6--2
File MIME type: text/javascript
#562100 by longwave, Antoine Solutions: Initial commit of the 6.x-2.x code.
1 // $Id$
2
3 function uc_aac_calculate(element) {
4 var form = $(element).parents('form');
5 form.ajaxSubmit({
6 url: Drupal.settings.base_path + "?q=uc_aac",
7 dataType: 'json',
8 success: function(data) {
9 // Replace HTML elements with new values.
10 var node = $('#node-' + data.nid);
11 for (var i in data.replacements) {
12 var replacement = $(data.replacements[i]);
13 $(node).find('.' + i).after(replacement).remove();
14 }
15
16 // Update the add to cart form.
17 if (data.form) {
18 var action = form.attr('action');
19 $(form).after(data.form).next().attr('action', action).uc_aac_attach();
20 form.remove();
21 }
22 }
23 });
24 }
25
26 jQuery.fn.uc_aac_attach = function() {
27 $(this).find('select[@name^=attributes]').change(function() {
28 uc_aac_calculate(this);
29 });
30 $(this).find('input:radio[@name^=attributes]').click(function() {
31 uc_aac_calculate(this);
32 });
33 }
34
35 $(function() {
36 $('.add-to-cart').uc_aac_attach();
37 });

  ViewVC Help
Powered by ViewVC 1.1.2