How to manually call a mouseup event in JavaScript?
August 14, 2007 12:13 PM
Subscribe
Need a way to complete a mousedown/mouseup event cycle in JavaScript, when said cycle is interrupted by a dialog box. Not sure if there's a way to "manually" call the mouseup event after the fact, or what.
I've got a multi-select form field, for which I'm trying to set up some JS to prevent accidental de-selection. Sounded simple enough, just have an onmousedown event that checks the current selection and pops up a confirm dialog if more than N items are selected.
Unfortunately, in the case where the user selects the affirmative answer - yes, I do want to just select the single list item I am clicking on, and de-selecting the 100 currently selected items is A-OK - the browser (FF 1.5 in this case) gets confused. It acts as if the mouseup event never occurred, so mouse movements cause the form field to act as if the user is clicking and dragging within the field (i.e. expanding the selection up or down from the item originally clicked upon). I assume this is because the user's mouse actions on the dialog box interrupt the event being handled by my onmousedown code.
Now, I don't consider myself a JS newbie by any stretch, but I can't for the life of me figure out how to solve this. Googling hasn't helped much due to the sheer volume of entry-level JS tutorials. I've tried utilizing formfield.click() but that doesn't change anything, and I can't find any obvious methods on the event object that might tell it to 'keep going'.
posted by cyrusdogstar to computers & internet (3 comments total)
From a usability perspective, it might also be better to put the confirmation in a div right below the field rather than a modal dialog.
posted by Sxyzzx at 1:06 PM on August 14, 2007