Defect #1636
closedUse of Prototype's Element-methods (like this.up("form"))
0%
Description
In /views/issues/_list.rhtml for example you use "this.up('form')". Actually the up-method is not available on the element itself, but only by the element, when it is returned by the $() method.
Quote from the Prototype-Documentation:
Prototype adds many convenience methods to elements returned by the $() function.
So, the correct way would be using: $(this).up('form') or Element.up(this,'form')
In IE7 the up method is actually not available on "this". In your case it's working "accidentially", because there is a call to $$('.hascontextmenu') executed somewhere in context_menu.js during page load, and by that the up-method is added to all DOM elements.
To better understand the problem check out this example (make sure to set the correct path and filename to prototype.js)
<html>
<head>
<script src="prototype-1.5.js"></script>
</head>
<body>
<form id='theform'>
<a id='thea' onclick='alert($(this).up("form").id); return false;' href='#'>CLICK HERE</a>
</form>
<script type='text/javascript'>
// the following call to $$() is what essentially makes it work in Redmine (called from context_menu.js via unselectAll):
$$('.hascontextmenu'); // COMMENT THIS LINE AND CLICK THE 'CLICK HERE' LINK TO SEE THE 'BUG' (in IE7)
</script>
</body>
</html>
Regards,
Chris
Updated by Jean-Philippe Lang over 17 years ago
- Status changed from New to Closed
- Target version set to 0.8
- Resolution set to Fixed
Fixed in r1667.
Thanks for your tip.