Created
August 11, 2010 07:52
-
-
Save kaievns/518654 to your computer and use it in GitHub Desktop.
RJS1 vs RJS2 example
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
/** | |
* the old Autocompleter constructor | |
* uses RightJS 1 and `Class` | |
*/ | |
initialize: function(input, options) { | |
this.input = $(input); // don't low it down! | |
this.$super(options); | |
// storing the callbacks so we could detach them later | |
this._watch = this.watch.bind(this); | |
this._hide = this.hide.bind(this); | |
this.input.onKeyup(this._watch).onBlur(this._hide); | |
this.holder = $E('div', {'class': 'right-autocompleter'}).insertTo(this.input, 'after'); | |
this.container = $E('div', {'class': 'autocompleter'}).insertTo(this.holder); | |
this.input.autocompleter = Autocompleter.instances[$uid(input)] = this; | |
} | |
/** | |
* new Autocompleter constructor | |
* using RightJS 2 and private dom-wrappers | |
*/ | |
initialize: function(input, options) { | |
this.input = $(input); // KEEP IT before the super call | |
this | |
.$super('autocompleter', options) | |
.insert(this.list = $E('ul', {'class': 'right-dd-menu'})) | |
.insertTo(this.input, 'after') | |
.onClick(this.clicked); | |
this.input.autocompleter = this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment