Skip to content

Type parameter in callback function for custom conditional events #2349

Closed
wants to merge 1 commit into from

4 participants

@bastianschilbe

This will work then:

Element.Events.textchange = {
base:'keyup',
condition: function(){return true}
};

​$('text').addEvent('textchange', function(e,t){
// e.type = keyup
// t = textchange
})​

@arian
MooTools member
arian commented Aug 8, 2012

@cpojer opinion did you ever need this? I think I would add it to the DOMEvent object instead of an argument... however sometimes that one isn't passed.. but in that case you can't pass the type either as second argument...

@arian
MooTools member
arian commented Oct 1, 2012

Why not:

var t = 'textchange';
​$('text').addEvent(t, function(e){
// e.type = keyup
// t = textchange
})​
@kentaromiura
MooTools member

Just like @arian highlighted this one seems a rather simple problem to circumvent using a closure.

also by using your fix, you're not acting coherent with the other event calling, this means that you'll need to change all these other event calling:

https://github.com/bastianschilbe/mootools-core/blob/4cd206e0281dbc3309102771956cbf0b8d43ce0d/Source/Element/Element.Event.js#L42

https://github.com/bastianschilbe/mootools-core/blob/4cd206e0281dbc3309102771956cbf0b8d43ce0d/Source/Element/Element.Event.js#L45

https://github.com/bastianschilbe/mootools-core/blob/4cd206e0281dbc3309102771956cbf0b8d43ce0d/Source/Element/Element.Event.js#L52

so in current form it couldn't be accepted.

also I think it shouldn't be an extra parameter too, but if it should be passed, it needs to be by decorating the event parameter, like real event does.

@cpojer
MooTools member
cpojer commented Oct 1, 2012

We are doing this for onAdd, onRemove and the condition. See 5d1eff8 If you need more fancy sugar use https://github.com/cpojer/mootools-custom-event

@cpojer cpojer closed this Oct 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.