I know how to do it, but I'm asking if there's a built-in way to do
this:
addEvent('click', this.doSomething.returnFalse(this));
rather than having to do:
addEvent('click', function(e){
e.stop();
this.doSomething();
}.bindWithEvent(this));
In the end I just used this:
Function.implement({
returnFalse: function(bind, args){
var self = this;
return function(){
args = (args != undefined) ? $splat(args) :
Array.slice(arguments,
(options.event) ? 1 : 0);
var returns = function(){
self.apply(bind || null, args);
return false;
};
return returns();
};
},
});
On Apr 21, 5:54 pm, ryan <[email protected]> wrote:
> event.stop() should do what you are wanting.
>
> so, something like
> function(e){
> e.stop();
> this.doSomething();
>
> }.bindWithEvent(this)
>
> On Apr 21, 2:17 pm, Lewis <[email protected]> wrote:
>
> > I may be missing something obvious but before I create my own, is
> > there a function to avoid me needing to do the following:
>
> > function(){
> > this.doSomething();
> > return false;
>
> > }.bind(this)
>
> > E.g. something like:
>
> > this.doSomething.bind(this).returnFalse();
>
> > Or even better being able to replace the bind function with
> > returnFalse. The $lambda function isn't really what I need since
> > doSomething could return true. I just need the "return false" part for
> > links, and having to keep creating functions manually seems
> > unnecessary.
>
> > So does this exist already.. or should I just create my own function
> > for it?