so that when the user draws a shape, the focus will be set to the respective href field, instead of the default behavior - adding new row(imgmap form).
but for brevity let me just simply the code..
$('elem_id').focus();
alert('Click here');
If i'll removed alert function, focus() won't do its job.
Alert is really disturbing.. can anyone explain why this is happening?
I've seen similar symptoms when someone tries to reference an element that isn't fully loaded yet. The alert() gives the browser sufficient time to continue loading and so the script works. When the alert() is removed the script does not work correctly.
Therefore, are you sure the element or whatever you are referencing before the alert(), is fully loaded by your browser before you try doing anything with it?
Unfortunately 2200+ lines is far too much code for me to look at with my limited attention span
I've seen similar symptoms when someone tries to reference an element that isn't fully loaded yet. The alert() gives the browser sufficient time to continue loading and so the script works. When the alert() is removed the script does not work correctly.
Therefore, are you sure the element or whatever you are referencing before the alert(), is fully loaded by your browser before you try doing anything with it?
Thanks for your reply tirna. You must be right with this assumption - maybe the element isn't fully loaded yet the time focus() fires up, may I know how would you deal with this kind of scenario, is there a way in PrototypeJS to suspend execution of focus() while the target element isn't fully loaded?
Originally Posted by tirna
Unfortunately 2200+ lines is far too much code for me to look at with my limited attention span
I've wish your editor could go to line at your request e.g. in notepad++, CTRL + 'g' would ask which line you want to go.
When the user clicks the + icon, various forms (including Href field) will be generated inside <div id="form_container" /> , he can draw map on the image, once the mouse has been release associated Href field should be focus(); see snippets from imgmap.js
Code:
//Codes here...
/**
* EVENT HANDLER: Handles mousedown on the image.
* Handles beggining or end of draw, or polygon/bezier point set.
* @param e The event object.
*/
imgmap.prototype.img_mousedown = function(e) {
//Emphasize only this area for brevity.
if (this.areas[this.currentid] == this._getLastArea()) {
//editor mode adds next area automatically
//if (this.config.mode != "editor2") {this.addNewArea();}
/*//////////////////////////////////////////////////////
this the code that triggers focus();
//////////////////////////////////////////////////////*/
if (this.config.mode != "editor2") {
$$('#img_area_'+this.currentid.toString()+' .img_href').first().focus();
alert('Click here.');
}
return;
}
return;
}
};
//Codes here..
Bookmarks