Download & Extend

jQuery 1.7: field_ui.js use attr for property

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

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: 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

#5

Status:active» needs review

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.

AttachmentSize
#1448494_3 replace field_ui.js_.patch 12.58 KB

#6

Status:needs review» needs work

Link is not working !

#7

space in name.. sorry

AttachmentSize
#1448494_3_replace_field_ui.js_.patch 12.58 KB

#8

Status:needs work» needs review

WTF

AttachmentSize
#1448494_3_replace_field_ui_js.patch 12.58 KB

#9

last try.. (sorry for the spam)

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

AttachmentSize
1448494_3_replace_field_ui_js.patch 12.58 KB

#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

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

#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

Status:needs work» reviewed & tested by the community

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

#16

The patch #9 also works for me

#17

Status:reviewed & tested by the community» needs review

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

AttachmentSize
1448494_17_replace_field_ui_js.patch 12.7 KB

#18

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

#19

Status:needs review» postponed

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

#20

Status:postponed» needs review

@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

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.

#23

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.

#24

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.

#25

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.

#26

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

#27

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

#28

Great news! Thanx ;)

#29

@gagarine :-p :)

#30

#27 Good news, friends! :)

@gagarine Great thanks!

#31

Thanks @gagarine! :) +1

#32

Status:fixed» closed (fixed)

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

#33

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

#34

Status:active» closed (fixed)

Not the same bug. Please open a new one.

nobody click here