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: Remove the states.js overwrite as it was fixed upstream)

  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

rokr’s picture

I tested these changes and can confirm this works. :-)

franzkewd’s picture

Tested this works. Cheers.

gagarine’s picture

Issue summary:View changes

Updated issue summary.

gagarine’s picture

Title:field_ui.js doesn't work properly with jquery 1.7» jQuery 1.7: attr methode doesn't accept property anymore and was replaced by prop
Priority:Normal» Major

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: Remove the states.js overwrite as it was fixed upstream. But field_ui.js is not added in drupal libraries so we can't access it via jquery_update_library_alter.

gagarine’s picture

Issue summary:View changes

Updated issue summary.

gagarine’s picture

gagarine’s picture

Status:Active» Needs review
StatusFileSize
new12.58 KB

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.

hles’s picture

Status:Needs review» Needs work

Link is not working !

gagarine’s picture

StatusFileSize
new12.58 KB

space in name.. sorry

gagarine’s picture

Status:Needs work» Needs review
StatusFileSize
new12.58 KB

WTF

gagarine’s picture

StatusFileSize
new12.58 KB

last try.. (sorry for the spam)

EDIT
Ok this one works! so no # in file name... I will remember.

pandaeskimo’s picture

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

gagarine’s picture

Title:jQuery 1.7: attr methode doesn't accept property anymore and was replaced by prop» jQuery 1.7: field_ui.js use attr for property
Status:Needs review» Needs work

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

gagarine’s picture

Issue summary:View changes

add link for states.js

jwilson3’s picture

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 ;)

filmoreha’s picture

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.

zkday’s picture

patch #9 working with me! thanks.

hswong3i’s picture

Status:Needs work» Reviewed & tested by the community

Also confirm that #9 works for me too. Thank you very much ;-)

mrsinguyen’s picture

The patch #9 also works for me

heyrocker’s picture

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new12.7 KB

Here's a reroll to current D7 head. It also fixes a documentation error.

heyrocker’s picture

I mean a reroll to current JQuery Update 2.2. Too much core dev going on in my life.

gagarine’s picture

Status:Needs review» Postponed

If this change passe in core this will works without change #1480568: use $.attr with false instead of empty string

ericduran’s picture

Status:Postponed» Needs review

@gagarine D7 isn't updating jquery to 1.7 any time soon. So this is still needed for D7.

gagarine’s picture

@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.

MustangGB’s picture

Status:Needs review» Postponed

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.

ericduran’s picture

Status:Postponed» Needs review

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.

gagarine’s picture

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.

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.

ericduran’s picture

Priority:Major» Critical

@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.

filmoreha’s picture

Does this fix (#9 or #17) work for filefield uploads as well?

gagarine’s picture

Status:Needs review» Fixed

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 ;).

klonos’s picture

Great news! Thanx ;)

ericduran’s picture

@gagarine :-p :)

Stan.Ezersky’s picture

#27 Good news, friends! :)

@gagarine Great thanks!

jacobroufa’s picture

Thanks @gagarine! :) +1

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

k_’s picture

Status:Closed (fixed)» Active

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 ... ?

gagarine’s picture

Status:Active» Closed (fixed)

Not the same bug. Please open a new one.

gagarine’s picture

Issue summary:View changes

Added the specific error message you get, for search purposes.

drecute’s picture

This affects drupal-6.x as well.