MooTools Morph “A is Null”

I’ve decided to post all the silly little things that I do and the resolutions to them.

If you’re coming across something like “A is Null” in MooTools – specifically MooTools Morph – make sure that you’re not passing a collection of elements.

For example, $$(’#element_identifier’), whilst only returning one element, will actually return a collection (albeit a collection containing one element!).

The solution is either use

var y = $$('#element_identifier');
var eldMorph = new Fx.Morph(y[0]);

Or use:

var eldMorph = new Fx.Morph($('element_identifier'));

As the single-dollar only returns one element, not a collection of elements.

While these things are obvious, for those who are playing around at the weekend or after work, it can be really frustrating if the answer isn’t a simple Google away.

Trackback URL

No Comments on "MooTools Morph “A is Null”"

Hi Stranger, leave a comment:

ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Subscribe to Comments