1

I'm currently creating a Channel Form that has a file field. Because of this, ExpressionEngine wants to include their Javascript and their version of jQuery (version 1.7.2).

In my wrapper template, I already include jQuery right before the close of the body tag (as per best practices at the time of writing). However, including jQuery creates collision errors and the file field has errors (won't allow me to delete files that are already uploaded and doesn't display the upload button.

I can add the parameter of include_jquery="no" to the Channel Form, which stops ExpressionEngine from loading their version, but the file field still doesn't work at this point.

If I move the inclusion of jQuery in my wrapper template to before the Channel Form (I put it in the head tag), it works correctly, which is what EllisLabs suggests doing. The problem is that I would prefer to leave jQuery at the bottom of the page, so that it doesn't block loading anything else.

Is there any way to keep jQuery at the bottom of the wrapper template, while also being able to use File Fields in Channel Forms?


As a minor note: the file field will also only work if you're using a slightly older version of jQuery (< 1.9), as it currently calls the .browser property, deprecated in 1.9

  • As a minor note: the file field will also only work if you're using a slightly older version of jQuery (< 1.9), as it currently calls the .browser property, deprecated in 1.9 – David Leitch Jun 27 '14 at 2:17
  • 1
    Is using jQuery in noconflict mode an option? – Steve Buzonas Jun 27 '14 at 3:02
3

I've had this same problem. I solved it by simply using {if segment_1 == "abc"} statements to not include my jQuery on any page (segment) that had Channel Forms loading it's own jQuery.

You can also overwrite the jQuery file that EE/Channel Form includes with your version of jQuery -- I have found EE's version to be slightly different to what I download from jQuery.com

| improve this answer | |
  • I used the same solution to selectively not add my own version of jQuery just on pages with channel forms. On all other pages it loads at end of body. – Benek Lisefski Jun 27 '14 at 8:01
  • Good ideas. I this this is probably the solution I'll use (only load jQuery on pages that don't have Channel Forms). Thanks for your input – David Leitch Jun 30 '14 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.