Skip to content

Type parameter in callback function for custom conditional events #2349

wants to merge 1 commit into from

4 participants


This will work then:

Element.Events.textchange = {
condition: function(){return true}

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

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...

MooTools member
arian commented Oct 1, 2012

Why not:

var t = 'textchange';
​$('text').addEvent(t, function(e){
// e.type = keyup
// t = textchange
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:

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.

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

@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.