mad4milk archive
mootools: extending HTML Elements with IE
September 06 2006, 13:53:00
Well, sorta… Let me explain: as you probably haven’t noticed, there’s a new small banner on the top-left on the main pages of this useless blog: mootools: coming september 8th.
Mootools is a new framework, a new library, a new call-it-as-you-wish set of scripts (Javascript ofcourse!) that was born to unify all the moo libraries ever released, but it has slowly become much more. …
YES yes the elements: with the Element.js component of mootools, which is a part of the core library, you can actually extend HTML Elements. How? Simply target one with the famous $ function (also $S and $E counts) and voila, extended. With all my properties. With all YOUR properties. I wont explain it in details here and now, but I will on release, in a couple of days. Ok just another couple of hints about Element.js, since you want it so badly:
to create an element from scratch? (let’s say a DIV) :
new Element('div')and to apply some styles to it? And maybe a className too?
new Element('div').setStyles({'height': '100px', 'width': '200px'}).addClassName('whatever')alright now I want it in the body!
new Element('div').setStyles({'height': '100px', 'width': '200px'}).addClassName('whatever').injectInside($E('body'))is this the only way?
$E('body').adopt('div').setStyles ...okay but I want an effect too!
$('myelement').addEvent('click', myFunction).effect('opacity').custom(0,1) ...
And just not to name a few of other features: Drag and drop with full support for drop-zones, events, a better Accordion, a nicer Ajax with Form and Objects Serializers, a revamped Fx, Dom with attribute queries and Sortable lists. Oh, and a better (but still compatible with prototype) Class, based on Base.js from Dean Edwards. All of this (and more) about 15kb of (well, this time compressed) code. But dont panic: you can always chose the components you want to get with a nice download manager. Need Drag but no Fx? no prob. Need Dom but no Ajax? its fine. With mootools you’ll always get what you need.
See you in a couple of days @ mootools.net! Do not ever type /download after it! Its still beta!