The Motionbox EventHandler in use

Sometimes you just have to like convenience. Using our EventHandler I was just able to write the following code:

JavaScript:
MOBX.HighlightTextField = (function() {
   
    var highlightText = function (evt) {
        var el = evt.element();
        el.focus();
        el.select();
    };
   
    MOBX.EventHandler.subscribe(".highlight_on_click", "click", highlightText);
})();

That could have been an anonymous module too. What's great is now whenever I want to have that "embed code" functionality I just add a class to the form element "highlight_on_click" and it will work as expected. No parsing the DOM for form fields and assigning observers, etc.

Nice.

No Comments Yet

You can be the first to comment!

Speak Your Peace

  • Comment Policy:Could go here if there's a nagging need Login Instructions: Would go here if there's a desire.