Problem/Motivation

There appears to be a long standing issue with the 2.52 version of jquery form that we are using that may be impacting the ability to upload files for Opera users. One runs into this issue while testing #1328900: Update to jQuery 1.7. Tests from JavaScript Tests | groups.drupal.org that don't work:

Uploading files: error here actually in jquery.form.js. Here's how to reproduce the uploaded error:

  1. With a fresh install created an article or a page.
  2. Try to upload a file.
  3. Notice that the throbber continues to rotate and the upload process never completes.

Also notice the following error is logged. The error is in /core/misc/jquery.form.js?v=2.52 line 12:

Uncaught TypeError: Object function ( selector, context ) {
  // The jQuery object is actually just the init constructor 'enhanced'
  return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'handleError'

Here are some other issue queues where the problem has been reported:

The issue reported above has been resolved since version 2.60 of jQuery Form. Their development team is currently on version 2.87.

Proposed resolution

Since we are in the process of updating javascript libraries with our move to jQuery 1.7, this is a great opportunity to update all of our javascript libraries. Starting with jQuery Form. Also see this, this update is important for the html5 initiative:

https://github.com/malsup/form/issues/100

Attached is a patch that updates to the latest update of git version of js.

Remaining tasks

Perhaps things will break if we adopted the latest/greatest version of this library. Great! We could then write the necessary javascript-based unit tests to test all of the interactions of this library with Drupal and reuse those unit tests for future development.

User interface changes

???

API changes

???

Original report by cosmicdreams

The original issue's summary is (mostly) copy-pasted from the now closed as duplicate #1338402: Update jQuery Form.

CommentFileSizeAuthor
#9 1203532-9.patch37.5 KBericduran
jquery.form_.patch34.92 KBkeichee
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Priority: Critical » Normal
marcingy’s picture

Category: bug » task
Status: Needs review » Needs work

This a task. And it should be minified.

rfay’s picture

Component: ajax system » javascript
andypost’s picture

Marked as duplicate #1338402: Update jQuery Form
Also it has great summary

klonos’s picture

Great summary indeed. That's why I copy-pasted it here ;)

Please take a look at it and correct where/as needed. Credits go to Chris Weber (cosmicdreams)

PS (off-topic): on issue summary preview the uploaded patch shows green as expected for a patch that passes tests. On plain display though it shows white - not indicating status on first look. Is this a known css issue of summaries on d.o.??

cosmicdreams’s picture

Cool, thanks for the shout out gang!

I've tried to contact @malsup on Twitter to get his insight on what changes we should call out in the UI changes and API changes sections.

ericduran’s picture

This is still missing work.

The system_library function needs to be updated to include the new version number.

Also the last version was minified this one isn't. I think is fine to have it unminified for now, but we probably should mention that we're doing that on purpose if we are. and create a seperate task to minified it before release D8.

catch’s picture

Category: task » bug
Priority: Normal » Critical

After #1328900: Update to jQuery 1.7 having these out of sync is a regression, bumping to critical.

ericduran’s picture

Status: Needs work » Needs review
FileSize
37.5 KB

Simple enough.

I lets the jquery.form.js unminified but I do think we'll eventually want to minified it.

catch’s picture

Title: jQuery Form Plugin update to latest git version » jQuery Form Plugin update to latest stable release

Re-titling since I think we're just upgrading to latest point releases at the moment. Thanks for the quick patching!

cosmicdreams’s picture

patch reported the following warnings:


git apply 1203532-9.patch
1203532-9.patch:61: trailing whitespace.
	
1203532-9.patch:103: trailing whitespace.
   
1203532-9.patch:156: trailing whitespace.
		var context = options.context || options;   // jQuery 1.4+ supports scope context 
1203532-9.patch:201: space before tab in indent.
            	// ensure that every serialized input is still enabled
1203532-9.patch:202: space before tab in indent.
              	for (i=0; i < a.length; i++) {
warning: squelched 9 whitespace errors
warning: 14 lines add whitespace errors.
ericduran’s picture

Yea, thats from the actual Jquery Form plugin. Not really sure if we should minified it ourself or not.

catch’s picture

I opened #1341792: [meta] Ship minified versions of external JavaScript libraries for minification of jquery.js et al. If there's no provided minified version I'm not opposed to minifying ourselves but that probably needs its own issue to discuss.

Could we open an upstream bug report for the whitespace errors maybe? Not sure how that works with jQuery plugins though.

cosmicdreams’s picture

Testing this now. Will take special interesting in whether this fixes file uploading

With this patch applied the main issue I was hoping it would resolve still persists:

as a content creator, I want to upload files to a node. Instead, this error occurs.

from line 12 of jquery.form.js

        Uncaught TypeError: Object function ( selector, context ) {
		// The jQuery object is actually just the init constructor 'enhanced'
		return new jQuery.fn.init( selector, context, rootjQuery );
	} has no method 'handleError'

Can someone verify if the issues I'm having are specific to my environment or if they are wide-spread.

ericduran’s picture

@cosmicdreams hmm, I'll test that. Is this with any file upload?

Is this new since the introduction on 1.7?

cosmicdreams’s picture

Yes it's with any file upload, I can only assume that it is an issue I am having since 1.7 since I can upload files with Drupal 7. But it might also be related to my development environment.

I'm using Ubuntu (latest) + SQLite as a backend database.

ericduran’s picture

I just tested this.

Ajax file upload is indeed currently broken in D8.

But after applying this patch, clearing my cache and testing again. Everything is now fixed.

I'll love for someone else to confirm so we can get this in.

Edit: I also submitted a patch to the jquery.form project (https://github.com/malsup/form/pull/151), so we can use their minified version instead and then we don't have to worry about all the line ending issues.

cosmicdreams’s picture

Cool, i'll reproduce your steps and see if i have a different result.

EDIT: OK, yes, that works. Man do I feel silly for forgetting to flush cache on testing a revised javascript.
Recommend RTBC

cosmicdreams’s picture

Status: Needs review » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Fixed

One advantage of having the minified versions in core is you don't have to look at the tabs, nothing we can do about that though and it makes sense to have unminified versions for debugging during this point in the cycle.

Committed/pushed to 8.x, thanks!

cosmicdreams’s picture

Awesome catch! Woohoo!

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

...(mostly) copy-pasting the summary from the now closed as duplicate #1338402: Update jQuery Form + conforming to the issue summary standards (http://drupal.org/node/1155816). Credits go to cosmicdreams.