So here is my solution, with two functions ... basic focus-select
function bindFocusSelect(selector)
{
$(selector).textbox('textbox').bind('focus', function(e){
$(selector).textbox('textbox').data('has-triggered', false);
$(selector).textbox('textbox').select();
});
}
The extra data attribute is intentional... to allow for "blur" or "enter" to trigger an event only once...
function bindTriggerEnterOrBlur(selector,myFunction)
{
$(selector).textbox('textbox').bind('blur keypress', function(e){
if (e.type == 'blur' || e.keyCode == 13) {
if (!$(selector).textbox('textbox').data('has-triggered')) {
$(selector).textbox('textbox').data('has-triggered', true);
// do something only once, not twice
myFunction();
// e.g., if I hit "[enter"] and tab to blur, I don't want it to call twice...
}
}
});
bindFocusSelect(selector);
}
The usage:
bindTriggerEnterOrBlur('#login-input-email',submitLoginEmail);
would call a function "submitLoginEmail()" without parameters
... or the most basic usage ...
bindFocusSelect('#login-input-email');