The Motionbox EventHandler in use
04.11.08 - 04:41pm
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);
})();
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.
Speak Your Peace