JavaScript-Frameworks and Conflicts with $
Posted: Sun Dec 06, 2009 9:25 pm
Hi
I ran into a problem with the use of $ in "my" plugins and I fear it's a problem we have to solve generally to avoid having incompatible plugins in Spartacus.
Almost all Javascript-Framworks use $. If more than one is used that leads to problems. This happens in s9y when the lightbox-plugin (using prototype) and commentedit or livecomment (using jQuery) are used. I fixed that in commentedit by calling noConflict and using jQuery instead of $, but wasn't aware that I of course have to do the same with the livecomment-plugin - in fact, all jQuery-code using $ will fail, also manually inserted one or code used in a template, if not modified accordingly.
So, I see two possibilities: 1. Only use one framework 2. All jQuery-code isn't allowed to use $.
The first possibility is very strict and could harm serendipity if something new, better, comes up, but if it's really only the lightbox-plugin, we could exchange that with a plugin using jQuery.
The second possibility could fail if we talk about more than two frameworks. Until know, I only know of prototype and jQuery being used, but what if another framework enters the stage which like prototype only wants to work with $?
Garvin, what do you think?
sincerely
I ran into a problem with the use of $ in "my" plugins and I fear it's a problem we have to solve generally to avoid having incompatible plugins in Spartacus.
Almost all Javascript-Framworks use $. If more than one is used that leads to problems. This happens in s9y when the lightbox-plugin (using prototype) and commentedit or livecomment (using jQuery) are used. I fixed that in commentedit by calling noConflict and using jQuery instead of $, but wasn't aware that I of course have to do the same with the livecomment-plugin - in fact, all jQuery-code using $ will fail, also manually inserted one or code used in a template, if not modified accordingly.
So, I see two possibilities: 1. Only use one framework 2. All jQuery-code isn't allowed to use $.
The first possibility is very strict and could harm serendipity if something new, better, comes up, but if it's really only the lightbox-plugin, we could exchange that with a plugin using jQuery.
The second possibility could fail if we talk about more than two frameworks. Until know, I only know of prototype and jQuery being used, but what if another framework enters the stage which like prototype only wants to work with $?
Garvin, what do you think?
sincerely