Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please use jQuery to refer to jQuery and not $ #685

Closed
kennypu opened this issue Jul 3, 2014 · 18 comments
Closed

Please use jQuery to refer to jQuery and not $ #685

kennypu opened this issue Jul 3, 2014 · 18 comments

Comments

@kennypu
Copy link

kennypu commented Jul 3, 2014

including parsley.min.js with a regular Wordpress install will cause an 'undefined is not a function', since the file is using $ to reference jQuery.

@gideonheilbron
Copy link

You should deregister the jQuery Wordpress is using and register the 'normal' one. Don't forget to NOT deregister when in admin. This will solve your problem.

@zslabs
Copy link

zslabs commented Jul 18, 2014

@gideonheilbron A vast majority of WordPress users may:

  1. Stop using ParsleyJS because it's not compatible straight out of the box and assume it's a defunct plugin
  2. Deregister the core jQuery and reregister a version number manually (which is a horrible decision for future maintenance compared to using a plugin I wrote; WP jQuery Plus
  3. Continue to post on Github the same exact issue until something is specifically set in the docs or it is addressed.

I believe you're saying jQuery noConflict is the issue here, right?

Also - you can't deregister jQuery in the admin anymore.

@kennypu
Copy link
Author

kennypu commented Jul 18, 2014

@gideonheilbron that is not a good solution, as it may break any wordpress plugins that rely on jQuery Wordpress.

It is bad practice to refer to $ anyways as it can be used for other libraries, not only jquery. I've seen it mentioned from time and time again (eg. http://www.sitepoint.com/10-tips-better-jquery-plugins/ #4)

@guillaumepotier
Copy link
Owner

Ok guys,

I tried to fix the non AMD jQuery requirement in order to not break things in Wordpress. Could you have a try at this version please? -> https://raw.githubusercontent.com/guillaumepotier/Parsley.js/master/dist/parsley.js

@kennypu
Copy link
Author

kennypu commented Jul 21, 2014

just tested on fresh wordpress install, yup it works (bottom left is the form): http://imgur.com/rGq4ssf,bV97Oy0

In comparison, ver 2.0.2 parsley.min.js (downloaded from the site) gave an error as shown:
http://imgur.com/rGq4ssf,bV97Oy0#1

@kennypu kennypu closed this as completed Jul 21, 2014
@guillaumepotier
Copy link
Owner

Great, I just released it as 2.0.3. Thanks guys for your feedbacks, enjoy!

@kennypu
Copy link
Author

kennypu commented Jul 21, 2014

thanks!!

@zslabs
Copy link

zslabs commented Jul 21, 2014

Thanks a lot!

  • Zach Schnackel

On Jul 21, 2014, at 6:00 AM, Kentaro Rose notifications@github.com wrote:

thanks!!


Reply to this email directly or view it on GitHub.

@joelcdoyle
Copy link

I am still having this issue with the latest version of WordPress, Bones theme, and the latest Parsley.js

How is that possible?

@marcandre
Copy link
Collaborator

But this is the official Parsley.js repo.

@joelcdoyle
Copy link

Yep, you're right. I got confused. I'm using Parsley 2.0.6, built just a few days ago. Did something change that would break this?

@marcandre
Copy link
Collaborator

I'm not familiar with wordpress, but did you include jQuery?

@joelcdoyle
Copy link

Btw, parsley require attributes still work, without calling

$('#myform').parsley();

But, data-parsley-equalto="#password" , for example, does not work. Plus, I get

undefined is not a function

if I try to call the above

@joelcdoyle
Copy link

jQuery is included in WordPress by default.

@marcandre
Copy link
Collaborator

Can you provide a link?

@joelcdoyle
Copy link

I wish I could, but it's a private project. 💩 Sorry, I know that doesn't help.

@joelcdoyle
Copy link

@joelcdoyle
Copy link

Thanks @marcandre. Changing the document ready function fixed my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants