stefangabos / Zebra_Form

A jQuery augmented PHP library for creating secure HTML forms and validating them easily
Other
98 stars 49 forks source link

interoperating with jQuery noConflict() #8

Open CBCNewMedia opened 10 years ago

CBCNewMedia commented 10 years ago

The jQuery function noConflict() removes the global references to jQuery so that you can safely use multiple versions of jQuery on a single page (multiple jQuery libraries is a necessary evil if you're working with a lot of third party embedded content).

The Zebra Form javascript code that is written out to the HTML page depends on the globals jQuery and $. If you're using noConflict(), those won't be available, and the client side validation won't work.

It would be great if we could specify an alternate name for jQuery. That way, we could safely put a reference to jQuery somewhere that Zebra Form can get to it.

Even better would be if all this code could run cleanly inside of a require.js module. We've wrapped up the static Javascript files in a require.js module, but that dynamically generated code is tricky. You would have to build a data structure with all the form's rules and make that available somehow to the require.js module. It's doable, but it's a pretty large change.

stefangabos commented 10 years ago

I am open to suggestions - even better, I accept pull requests! :) Having the code inside a require.js module makes everything too particular, but maybe an extra property given to the clientside_validation method is what we need

SimonMayerhofer commented 8 years ago

If somebody wants a temporary solution: Just search for "$(" in Zebra_Form.php and replace all with "jQuery(". This did resolve the errors in the console for me.