As you can see from the links in reference part of my previous email,
these are hardly MooTools "subjects", it's basic JavaScript, except
for Function.prototype.pass, which has a description and example(s) in
the docs I linked. If you didn't know about Function.prototype.bind,
Function.prototype.call and Function.prototype.apply, I'd strongly
recommend diving into JavaScript basics a bit more.

On 24 February 2014 13:14, Vladimir Prieto <[email protected]> wrote:
> theres is a lack of examples on mootools docs about this subject.
>
> think somebody can put some better examples on it.
>
> thanks for the info!
>
> El lunes, 24 de febrero de 2014 08:44:32 UTC-3, Tim Wienk escribió:
>>
>> There are a few ways to "bind" a function to an object. Some of those
>> ways will return a new "version" of that function, others will execute
>> the function immediately.
>>
>>
>> Let's assume `var fn = function(arg1, arg2){}`, then:
>>
>>
>> `var boundFn = fn.bind(this, "a", "b")` will make `boundFn` a new
>> "version" of `fn` bound to `this` and with arguments "a" and "b".
>>
>> `var boundFn = fn.pass(["a, "b"], this)` will do the same using a
>> different syntax.
>>
>>
>> `var result = fn.call(this, "a", "b")` will execute `fn` as if it's
>> "bound" to `this` with arguments "a" and "b".
>>
>> `var result = fn.apply(this, ["a, "b"])` will do the same using a
>> different syntax.
>>
>>
>> In the case you mentioned in your last email, instead of using
>> `searchCustomer.pass([event, id], this)()`, you can skip the "pass"
>> step by using `searchCustomer.call(this, event, id)`.
>>
>>
>> Reference:
>>
>> fn.bind:
>>
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
>>
>> fn.pass:
>> http://mootools.net/docs/core/Types/Function#Function:pass
>>
>> fn.call:
>>
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
>>
>> fn.apply:
>>
>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
>>
>>
>> On 24 February 2014 12:26, Vladimir Prieto <[email protected]> wrote:
>> > searchCustomer.pass([event, id],this)();
>> >
>> > did the trick!
>> >
>> > thanks again
>> >
>> >
>> > El lunes, 24 de febrero de 2014 08:18:02 UTC-3, Vladimir Prieto
>> > escribió:
>> >>
>> >> Thanks! that works.
>> >>
>> >> but..how can i bind searchCustomer to send it this object ?
>> >>
>> >> searchCustomer(event, id).bind(this);
>> >> searchCustomer.bind(this,event, id);
>> >>
>> >> those ones didn't work.
>> >>
>> >> El lunes, 24 de febrero de 2014 06:48:02 UTC-3, Aicke Schulz escribió:
>> >>>
>> >>> Maybe this helps you a bit, had to strip down some code, and control
>> >>> doesn't seems to work in jsfiddle so its in comments
>> >>>
>> >>> http://jsfiddle.net/4RpnF/2/
>> >>>
>> >>> Am Montag, 24. Februar 2014 10:09:14 UTC+1 schrieb Vladimir Prieto:
>> >>>>
>> >>>> been updated a class i made some time ago from mootools 1.2.
>> >>>>
>> >>>> http://jsfiddle.net/vladimirprieto/4RpnF/
>> >>>>
>> >>>> but i can't find a way to do it on moootools 1.4.  as far as i
>> >>>> search, i
>> >>>> have to do it with pass and/or bind, but i couldn't.
>> >>>>
>> >>>> can anybody give me hand on this?
>> >>>>
>> >>>> thanks!
>> >
>> > --
>> >
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "MooTools Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [email protected].
>> > For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>> --
>> Tim Wienk, Software Developer, MooTools Developer
>> E. [email protected] | W. http://tim.wienk.name
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "MooTools Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.


-- 
Tim Wienk, Software Developer, MooTools Developer
E. [email protected] | W. http://tim.wienk.name

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to