3.2.0

Conflicts with other javascript libraries?

I have tried to use AW alongside some other DHTML libraries (for things like drap and drop, sortable lists, effects etc.) and experienced some problems.

For example, when using a library called "Scriptaculous" (which, together with "Rico" I understand uses a library called "Prototype"), Active Widgets doesn't display data in cells correctly (seems to put a whole row of data in a single cell) - this seems to occur in IE whereas in FF things seem OK.

Maybe it's no surprise that with a cocktail of javascript from different sources you are going to run into problems. I just wonder if people might be able to share experience of using any of these kind of libraries successfully alongside AW.

Many thanks
Will
Will
October 20,
Will,

There is usually one main reason for compatibility problems - trying to modify functionality of the standard objects. AW did this in 1.0 to provide IE emulation layer in Firefox which was very convinient but unfortunately broke compatibility with some libraries which were 'fooled' into thinking that they work in IE while it was in fact Firefox. So in 2.0 this will be removed (but it is not fully done in 2.0b1).

Prototype library as far as I know does something really bad. It modifies properties of the global object prototype (i.e. all js objects). This is very bad practice because after you done that you cannot any longer use for each loop and other standard javascript features.

Hopefully Prototype developers will realize that this is a serious problem and correct this in the future.
Alex (ActiveWidgets)
October 24,
Example of the offending code from prototype.js

Object.prototype.extend = function(object) {
  return Object.extend.apply(this, [this, object]);
}


This is something you should NEVER do (modifying Object.prototype)!!!
Alex (ActiveWidgets)
October 25,
Update:

Current version of AW includes 'protection' against the code which adds new methods to the built-in types (like the example above) so it should be able to work with Prototype and it's derivatives.

Also the new version of the Prototype (1.4.0) makes less damage as the Object.prototype is no longer modified, though Array.prototype and String.prototype still are :-(
Alex (ActiveWidgets)
January 22,
Thank you all very much for the useful information.

Joe
Joe Hudson
January 22,
Just curious Alex, does this mean that Beta 4 should be robust against using Array.prototype to define additional prototype methods?

If so, I'm slightly concerned as pages containing grids failed both when I tried to use Beta 3 and Beta 4 with the problem described by Will.

Is there any way to get around this in AW?

Thanks again
Helen Williamson
January 24,
Unfortunately not, I was trying to make the grid compatible with adding new methods to Object.prototype and Array.prototype but apparently the problem still exists. It should be fixed in RC1.
Alex (ActiveWidgets)
January 24,

"This is very bad practice because after you done that you cannot any longer use for each loop and other standard javascript features."

Yup, this is very annoying. My way around it is to use struct instead of associative arrays:

instead of:
cars["ford"] = "mondeo";
cars["audi"] = "A4";
cars["opel"] = "vectra";

I do :
var cars = { "ford" : "mondeo", "audi" : "A4", "opel" : "vectra" };

works great, and shouldn't have any special overhead.

For indexed arrays you do the old school:

for ( var i = 0; i < cars.length; i ++ )
....

which is definitely less convenient then just a for ( var i in cars ) ...
but u might use one of the prototype method like each and feed it with some lambda style function.

Bart
April 13,
As far as I know the final AW 2.0 release works fine with Prototype/Scriptaculous.
Alex (ActiveWidgets)
April 13,

This topic is archived.

See also:


Back to support forum