JavaScript-Frameworks and Conflicts with $

Creating and modifying plugins.
Post Reply
onli
Regular
Posts: 3044
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

JavaScript-Frameworks and Conflicts with $

Post by onli »

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
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: JavaScript-Frameworks and Conflicts with $

Post by yellowled »

onli wrote:if it's really only the lightbox-plugin, we could exchange that with a plugin using jQuery
Personally, I have to say I find prototype's "why should we, if it works with prototype only" approach kind of ... erm ... odd, and I'd consider it a reason to not use prototype. At all. Especially in a system which is extendable by plugins.

Anyway, there is at least a jQuery only implementation of LightBox. We'd have to check if there are implementations of other lightbox clones as well to fully replace the current plugin with a more reasonable alternative. Which I'd be in favor of.

YL
Post Reply