I cannot get focused to update with the current value. Is there a bug in this code or is there a cleaner approach I am missing? Can I pass 'this' or the 'event'?
I am getting this error:
'focused is not defined'
I have this block of code:
$("input, select, textarea, button, .link, div, .button").live({
click:clearDefault,
focusin:function() {focused = ($(this).attr('title'))},
focusout:function() {focused = false},
mouseover:onHelp,
mouseout:helpFallback
});
Which maps to these functions:
function onHelp() {
if (!helpDiv) {
helpDiv = $('#helpText');
}
var $this = $(this);
var text = $this.attr('title');
if ($this.attr('titlehtml')) {
var text = $this.attr('titlehtml');
}
if ($this.hasClass('screenshot')) {
text += "<img src='images/icon_table_" + $this.attr('id') + ".png' >";
}
if ($this.attr('errorhtml')) {
text += "<div id='userError'>"+$this.attr('errorhtml')+"</div>";
}
helpDiv.show().html(text);
}
function helpFallback() {
if (focused) {
helpDiv.show().html(focused);
} else {
helpDiv.hide();
}
}
Define focused as below and set some default value
var focused = false;