Ticket #3523 (closed bug: fixed)
Dialog: onclick return value ignored
| Reported by: | BrianHV | Owned by: | scott.gonzalez |
|---|---|---|---|
| Priority: | major | Milestone: | 1.8.5 |
| Component: | ui.dialog | Version: | 1.6rc2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
The onclick return value on a link is being overridden when that link is added to a modal dialog.
In the following code sample, clicking the first link correctly does nothing when it's not in a dialog. Clicking the second link places the first into a dialog, at which point the first link causes navigation despite the false return value.
This bug was discovered in 1.6rc2 and confirmed to still be present in trunk.
<html>
<body>
<script type="text/javascript" language="javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript" language="javascript" src="ui/ui.core.js"></script>
<script type="text/javascript" language="javascript" src="ui/ui.dialog.js"></script>
<p><a href="nowhere.html" id="brokenlink" onclick="return false;">This link shouldn't do anything, but when it's in a dialog it does.</a></p>
<p><a href="#" onclick="$('#brokenlink').dialog({modal: true});">Open dialog</a></p>
</body>
</html>
Change History
comment:1 Changed 5 years ago by scott.gonzalez
- Owner changed from paul to scott.gonzalez
- Component changed from ui.core to ui.dialog
comment:2 Changed 4 years ago by scott.gonzalez
- Priority changed from minor to major
- Milestone changed from TBD to 1.6
comment:4 Changed 4 years ago by scott.gonzalez
- Status changed from new to closed
- Resolution set to worksforme
This works for me, tested against 1.6rc2 and trunk (1.8pre).
comment:5 Changed 3 years ago by jlesueur
This behavior is browser-specific, IE8 still behaves this way with jquery-ui 1.8. This is the slightly modified(to use newer versions of jquery) code to reproduce on IE8
<html>
<body>
<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryu
i/1.8/themes/base/jquery-ui.css" rel="stylesheet" />
<p><a href="nowhere.html" id="brokenlink" onclick="return false;">This link shouldn't do anything, but when it's in a dialog it does.</a></p>
<p><a href="#" onclick="$('#brokenlink').dialog({modal: true});">Open dialog</a></p>
</body>
</html>
comment:6 Changed 3 years ago by jlesueur
- Status changed from closed to reopened
- Resolution worksforme deleted
comment:7 Changed 3 years ago by scott.gonzalez
- Summary changed from onclick return value ignored in dialog to Dialog: onclick return value ignored
comment:8 Changed 3 years ago by scott.gonzalez
- Status changed from reopened to closed
- Resolution set to fixed
- Milestone changed from 1.8 to 1.9
Fixed in af9864d.
comment:10 Changed 2 years ago by Scott González
Dialog: Don't return true when we don't want to cancel events. Fixes #3523 - Dialog: onclick return value ignored.
Changeset: af9864dcc439bf8d04f4ade248725cc217f66d56

