Active
Project:
Ubercart Payment Method Adjustments
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2010 at 13:44 UTC
Updated:
18 Aug 2012 at 17:46 UTC
On uc_pma.js there is an error with the radio buttons Jquery selector. The subtotal don´t update because the event don´t fire.
On line 7:
$("input:radio[@name='panes[payment][payment_method]']").click(
you need to escape the "[]" symbols:
$("input:radio[@name='panes\\[payment\\]\\[payment_method\\]']").click(
Comments
Comment #1
longwaveI can't reproduce this using the default version of JQuery included with Drupal 6, in fact if I make the change you propose then the selector no longer works. Are you running jquery_update?
Comment #2
carlitus commentedI have the same issue. In my Drupal it works with this code:
$("input:radio[@name='panes\\[payment\\]\\[payment_method\\]']").click(
(only escaping the [] symbols within simple cuotes)
And yes, i have jquery update module enabled.
Comment #3
jaydubb181 commentedI have the latest jQuery update running at 1.3.2. Adding the slashes to the selector fixed this issue for me. Thanks!
Comment #4
longwaveSo we need to find a way of making this work whether jquery_update is installed or not...
Comment #5
wojtha commentedHi, I meet this issue yesterday. Since jQuery 1.3.2 all weird characters used in ID, NAME or CLASS attributtes have to be escaped by double backslash "\\" as Limay and Carlitus mentioned before.
I suggest something like this:
You can play around with example which I provided at jsFiddle.net
Another solution is selecting RADIOS using theirs parent element with some stable ID (I mean ID which is not dependant on some theme tweaks and doesn't include weird characters) ...
I think this could play pretty nice:
Comment #6
longwave$("#payment-pane input:radio")looks much simpler but there could be a case where a specific payment method uses another set of radio buttons in its own option form.What about using that method, but with a wildcard attribute:
$('#payment-pane input:radio[name*="payment_method"]')?Comment #7
wojtha commentedok it could work if some of these specific payment methods radio buttons sets do not include that string in theirs name...
Another alternative could be injecting some unique CSS class or ID in hook_form_alter() to panes[payment][payment_method] radios. So we can select them easily...
Oh wait, and what about this?
ID strings are "weird characters free" so it allows us to be more specific and it will work in all jQuery versions...
Comment #8
wojtha commentedAnyway I suggest some more changes.
1) Implement drupal.behaviors + context instead of document.ready (I know that in UC developers don't implement it, but they should, it is right way how to do it in Drupal - especially with jQuery 1.2.6, without $.live() support). Also adding uc-pma-processed class should be considered to avoid duplicate bindings.
2) Make URL in JS more flexible - if you write URL in the way like base_path + 'some/url' it can't be modified by url_rewrite_inbound and outbound so it will not work on sites which uses modules which rewrites URL like 118n. The implementation of solution this is relatively easy, I suggest this solution to UC developers, year ago and they implement it in UC2.1 or 2.2 I believe.
3) Change name of internal functions in the module to respect of Drupal Standards. There are some special cases like dpm() or dvm() etc. from devel module, but I think that payment_method_adjustment_description() or _payment_method_adjustment() aren't privileged in any aspect...
4) Initialize all variables. (yes I'm pedantic ;-) )
Output from php-initialized tool
Should I post separate issues for all that things?
Comment #9
longwaveI don't think we need separate issues, I would just repost them under a single new "code cleanup" issue so we can concentrate on the jQuery bug here. And as well as posting issues, if you want to provide patches that would be even more useful ;) Otherwise I'll try to find some time to spend on fixing up this module in the next week or so.
Comment #10
bserem commentedI just run into this problem. First time I'm using uc_pma with jquery_update in the same site.
I was searching for AJAX problems in uc_pma and It took 2 days to find this post but here I am.
I tried the patch longwave gave (http://drupal.org/node/992630) but with no luck. Have you succeded in finding a solution to this?
Comment #11
tajindersingh commentedJust today faced this bug and saw this post. So, here is the solution in case anyone else reaches here.
Open uc_pma.js, now in code $("input:radio[@name='panes[payment][payment_method]']").click remove that @ sign before "name" because jquery 1.3 dropper this type of selectors were dropper.
Refer Note on page http://api.jquery.com/category/selectors/attribute-selectors/