This project is archived and is in readonly mode.

#134 ✓invalid
Jed

Events.removeOn Breaks Functionality

Reported by Jed | June 17th, 2008 @ 03:35 AM | in 2.0 (closed)

[sorry if this is not the best place for this, it seems like a bug to me, personally I'd like it changed but the devs might disagree. please don't just mark invalid with no comment, thanks!]

I have a lot of controls (buttons, radios, checkboxes, etc) which use events internally for managing their state, and externally for making functionality available.

To indicate external events, I've used the 'onEvent' style, which integrates nicely with Options. eg. 'onPress', 'onDisable', etc. These events are used for hooks, so when you press a button something happens.

Internal events just use the event name, eg. 'press' 'disable'. These events are mainly used to update button status, eg. the style manager updates the appearance to reflect the button being pressed.

As of the recent change with 'removeOn', all this is broken. We can no longer use this syntax to differentiate event types. Aside from my UI Library being largely broken now, there are all sorts of gotchas here! For example my 'disable' event fires the 'onDisable' event, creating an infinite loop!

I love MooTools and all the other wonderful changes that come with 1.2, but this seems like a really broken change that was added at the last minute - and honestly, it worked fine before. JS programmers are used to variables being case-sensitive, so why should suddenly 'myEvent' override 'myevent'?

Fixing the 'click'/'onClick' mess for built-in element events was great... breaking custom events is not, my 2c.

Is there any chance of this going back the way it was in 1.2b2? Thanks!

Comments and changes to this ticket

  • Jed

    Jed June 17th, 2008 @ 03:37 AM

    EDIT - When I say override above, I meant overlap with! Each function bound to an event is distinct so there is no overriding, but if I fire 'press' I may not want 'onPress' to be fired as well!

  • Jan Kassens

    Jan Kassens July 17th, 2008 @ 06:22 PM

    • State changed from “new” to “invalid”
    • Tag set to 1.2release, breakingchange, core, events

    seperating internal and external events by the on prefix was/is probably only used by you. You should either suffix them with "internal" or just call the function.

  • Jed

    Jed July 18th, 2008 @ 03:38 AM

    • Tag changed from 1.2release, breakingchange, core, events to 1.2release, core, docs, events

    I've updated all our code so it uses an undersore suffix to separate internal and external events, so this is no longer a problem for me.

    It still seems counter-intuitive that event names are changed... It's mentioned under 'Notes' but you have to be concentrating to pick it up - it's pretty obscurely explained.

    Perhaps a more significantly styled 'note' or 'warning', along the lines of

    NOTE: Event names starting with 'on' are automatically converted to the event name without 'on', so 'onComplete' becomes 'complete'. The same happens when firing events, so calling classInstance.fireEvent('complete') is the same as classInstance.fireEvent('onComplete').

    thanks,

    Jed.

Create your profile

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

Shared Ticket Bins

People watching this ticket

Tags

Pages