This project is archived and is in readonly mode.

#34 ✓resolved
Scott Kyle

Class.Binds requires initialize

Reported by Scott Kyle | April 17th, 2009 @ 09:56 PM | in 1.3.1.1

Class.Binds was refactored for 1.2.2 in a nice way, but using initialize as a mutator means that Binds will not work on a Class without an initialize method, which is not usually required for a Class.

It should set the initialize in the mutator:


Class.Mutators.Binds = function(binds){
	var initialize = this.initialize;
	
	this.initialize = function(){
		$splat(binds).each(function(name){
		var original = this[name];
			if (original) this[name] = original.bind(this);
		}, this);
		return initialize ? initialize.apply(this, arguments) : this;
	};
	
	return this;
};

Sidenote: I personally don't care for having to list out each method you want bound. I wrote about my BindAll mutator for 1.2.1 that binds all methods. It'll be adapted for 1.2.2...

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The MooTools Extensions

Referenced by

Pages