-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
window beforeunload triggered from chosen click, IE 8 & 9 #403
Comments
Just more info... I believe this is all tied to the fact that container_div is an anchor and any anchor click in IE is going to trigger beforeunload. So, def seems best to return false from container.click always also see in latest source that there is no longer a click handler, rather just mousedown. So, problem exists in current branch - I'll work on a patch. |
Even after returning false the beforeunload event is getting triggered in IE8. For IE9, adding 'onclick="return false;" ' in markup for '<a href='javascript: void(0)'...' element avoided this issue. returning false in container_mousedown function did not help either for IE8. Did you find another solution or better hack for this? Thanks. |
Hi, yes, my pull request has the fix I found - evt.preventDefault() in click handler. Should work for you, let me know. thanks. |
Is this a duplicate of issue #337? |
I am using sammy.js in my app and found that in IE8 and 9 it would sporadically stop working. I tracked it down today to chosen causing 'beforeunload' on window to be triggered when the dropdown is clicked. Sammy is bound to that and unloads itself. It's not clear to me what is causing beforeunload to trigger.
To reproduce, just open harvesthq.github.com/chosen test page in IE8 or 9, start developer tools (f12) and click 'start debugging' on script tab. In console bind to 'beforeunload':
$(window).bind('beforeunload', function() {alert('in before');});
and then click on any of the chosen dropdowns and see alert.
any help appreciated.
-- UPDATE
after some googling found some threads re: IE triggering beforeunload and a suggestion to return false from the click handler to prevent this. I confirmed that changing Chosen.prototype.container_click() to return false resolved this behavior in IE - or better still, calling preventDefault() on the evt passed into click().
The text was updated successfully, but these errors were encountered: