Posted by ericduran on February 21, 2012 at 7:14pm
38 followers
| Project: | jQuery Update |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
In jQuery 1.7 attr methode doesn't accept property anymore and was fully replaced by prop. This break the field admin and possibly other things as well. When adding a field, you get the following error message, even when you select the correct widget.
Add new field: you need to select a widget.
We have this problem in various places.
A quick fix is to replace .attr to .prop like this.
/misc/states.js (solved #1448490: fix states.js upstream and remove the overwrite in jQuery Update)
252: return this.prop('checked');
389: $(e.target).prop('checked', e.value);/modules/field_ui/field_ui.js (harder because not a library)
93: $(this).html(html).prop('disabled', disabled );
246: $(ajaxElements).prop('disabled', true);In comment #3 I propose instead to overrid jQuery's attr function.
This issue is coming from #1386294: Release jQuery 1.7 for Drupal 7.
Comments
#1
I tested these changes and can confirm this works. :-)
#2
Tested this works. Cheers.
#3
Hacking the core is definitely not the way to go. I propose we Overrid jQuery's attr function instead with a backward compatible one. In short: attr function has to accept property and redirect them to prop.
I'm curious if http://www.bennadel.com/blog/1624-Ask-Ben-Overriding-Core-jQuery-Methods... will work in drupal environment.
Jquery 1.6.1 attr methods add a logic to make it backward compatible, we can check it for inspiration.
The big advantage, this will also works with contrib module. I don't think it will hit performance to badly.
EDIT
I first thought than we can use the same method than #1448490: fix states.js upstream and remove the overwrite in jQuery Update. But field_ui.js is not added in drupal libraries so we can't access it via jquery_update_library_alter.
#4
Corresponding Core issue #1494714: Add field_ui.js in drupal library (so it can be overwrited)
#5
Her a patch than simply replace field_ui.js with a working one. It's easy but I'm still thinking replacing the jQuery's attr function would be better.
#6
Link is not working !
#7
space in name.. sorry
#8
WTF
#9
last try.. (sorry for the spam)
EDIT
Ok this one works! so no # in file name... I will remember.
#10
gagarine,
Thanks for the work.
FYI, the patch naming convention is (module_name)-(description)-(issue_number)-(comment_number).patch.
for example, field_ui-replace-field-ui-js-1448494-3.patch.
Not sure how we should tackle this, but here is a link to an issue I'm working on which uses a conditional statement to preserve compatibility with jQuery pre 1.6, #1494860: Views Rewrite Results UI Broken using JQuery 1.7
#11
I created #1498858: [meta] attr and prop so we can discuss generally about the problem.
Need work because we need to replace the JS only for 1.7. I can just read the variable.
I will try to remember the convention... But why it's not documented right under the upload field :P
#12
I've added the exact error message you get to the issue summary. As a work around for someone who needs 1.7 on the front end, but also needs to create new fields... just temporarily switch back to 1.5 in order to create the field, and then set it back to 1.7, from the Jquery Update admin UI ;)
#13
I grappled with the best way to tackle this issue and ended up going with overriding front end jQuery with hook_js_alter() in my template.php to load jQuery 1.7.2 and using a separate backend end them to keep everything in working order. It's just a cleaner easier approach IMHO.
I am not sure if the hook_js_alter() method works with jQuery Update though (can a dev verify if it still works for jQuery UI update?), so your mileage may vary. I personally disabled jQuery Update.
#14
patch #9 working with me! thanks.
#15
Also confirm that #9 works for me too. Thank you very much ;-)
#16
The patch #9 also works for me
#17
Here's a reroll to current D7 head. It also fixes a documentation error.
#18
I mean a reroll to current JQuery Update 2.2. Too much core dev going on in my life.
#19
If this change passe in core this will works without change #1480568: use $.attr with false instead of empty string
#20
@gagarine D7 isn't updating jquery to 1.7 any time soon. So this is still needed for D7.
#21
@ericduran look at the patch in #6. I'm just correcting bad coding in field_ui.js than should make it compatible with all version of jquery.
#22
If #1480568: use $.attr with false instead of empty string gets committed the issue is fixed in a much nicer way so this patch is redundant.
#23
Yes, but it should be noted. The problem only shows up when running jquery_update so jquery_update introduces the issue and I think for now it should fix the issue.
When that problem is fixed in core that's fine but for now jquery_update should fix the problem it introduces. So lets get this fixed here, it'll be a lot faster.
#24
It's bad code at the first time. We can work on a patch on this issue, but this would be stupid: in 2 weeks we can make an other patch than delete the work we eventually commit as the bug is going to be solve in core.
For now, if you want to help follow the other issue.
#25
@gagarine I'm on the other issue, I completely undertand the issue is a code change in core. But I hate to be the one to say this but I highly doubt that is going to get fix in D8, back ported to D7 and release in 2 weeks. especially since the issue has been open for uhm 2 months now.
This is not a Major issue in core because the problem is only introduce when running the latest Jquery (1.7) which is why it should just be fixed here first!
Also bumping this up to critical as this is one of the most annoying issues now a days.
#26
Does this fix (#9 or #17) work for filefield uploads as well?
#27
Ok everyone.. this is fixed in core now :).
So just wait the next drupal version and it will magically works..
http://drupalcode.org/project/drupal.git/commit/74de092
#1480568: use $.attr with false instead of empty string
@ericduran ok not 2 weeks... but 23 days ;).
#28
Great news! Thanx ;)
#29
@gagarine :-p :)
#30
#27 Good news, friends! :)
@gagarine Great thanks!
#31
Thanks @gagarine! :) +1
#32
Automatically closed -- issue fixed for 2 weeks with no activity.
#33
updated core to 7.15
re dl'd/installed a new/fresh jquery_update
did NOT apply patch #1448494
@ edit of a form, e.g. "/node/14/webform"
add a "Select list" field
select/open to edit
Select Options
attempt to edit (add, change, reorder) the available options ('one', 'two', 'three') -> nothing possible / nothing happens.
disable jquery_update, all's back to normal.
unclear atm whether it's the exact same issue, but ... definitely a jquery_update dependency again
EDIT:
applying the patch to 7.15 + jquery_update 2x-dev,
patch -p0 < ../1448494_3_replace_field_ui_js.patch
patching file jquery_update.module
patching file replace/modules/field_ui/field_ui.js
seems to have no effect on the @webform editing I'm trying. something different ... ?
#34
Not the same bug. Please open a new one.