Created
December 15, 2010 16:17
-
-
Save kaievns/742181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple custom wrapper | |
var Widget = new Class(Element, { | |
initialize: function(raw_element) { | |
// calling the Element's constructor | |
this.$super(raw_element, { | |
'class': 'my-widget' | |
}); | |
}, | |
// some other custom methods | |
}); | |
var widget = new Widget(document.getElementById('my-element')); | |
// basically any time you create an instance of an `Element` class | |
// or it's subclass, RightJS will register the last instance as | |
// the default wrapper, so even if an element was already wrapped | |
// it will be rewrapped again, say like that | |
$('my-element'); // -> Element | |
new Widget($('my-element')._); | |
$('my-element'); // -> Widget |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment