Skip to content

The Motionbox EventHandler in use

by Topper on April 11th, 2008

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

[js]
MOBX.HighlightTextField = (function() {

var highlightText = function (evt) {
var el = evt.element();
el.focus();
el.select();
};

MOBX.EventHandler.subscribe(“.highlight_on_click”, “click”, highlightText);
})();
[/js]

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.