The Motionbox EventHandler in use
Sometimes you just have to like convenience. Using our EventHandler I was just able to write the following code:
-
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.
