| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <title>IE onclick + live</title> |
|---|
| 4 | </head> |
|---|
| 5 | <body> |
|---|
| 6 | |
|---|
| 7 | <script type="text/javascript" src="../../dist/jquery.js"></script> |
|---|
| 8 | <script type="text/javascript"> |
|---|
| 9 | liveIEinlinecount = 0; |
|---|
| 10 | $('<a id="liveIElink" href="javascript:void(liveIEinlinecount++);" onclick="return false;"><span>link</span></a>').prependTo('body'); |
|---|
| 11 | $(".whatever").live("click", function(event) { |
|---|
| 12 | event.preventDefault(); |
|---|
| 13 | }); |
|---|
| 14 | // the interval in to avoid using alerts and provide feedback for debug |
|---|
| 15 | setInterval(function(){ |
|---|
| 16 | $('#testarea').html(liveIEinlinecount); |
|---|
| 17 | jQuery('#liveIElink').click(); // this doesn't trigger the bug |
|---|
| 18 | jQuery('#liveIElink span').get(0).fireEvent('onclick'); // this also doesn't trigger the bug |
|---|
| 19 | },1000); |
|---|
| 20 | |
|---|
| 21 | /* draft for Unit Tests |
|---|
| 22 | |
|---|
| 23 | // Verify that livehandler don't return true firing inline events in IE |
|---|
| 24 | liveIEinlinecount = 0; // global on purpuse |
|---|
| 25 | jQuery('<a id="liveIElink" href="javascript:void(liveIEinlinecount++);" onclick="return false;">link</a>').appendTo('body'); |
|---|
| 26 | jQuery('#liveIElink').click(); |
|---|
| 27 | equals( liveIEinlinecount, 0, "inline click" ); |
|---|
| 28 | liveIEinlinecount = undefined; |
|---|
| 29 | jQuery('#liveIElink').remove(); |
|---|
| 30 | |
|---|
| 31 | */ |
|---|
| 32 | </script> |
|---|
| 33 | <div id="testarea"></div> |
|---|
| 34 | <div>The above number should always be 0, regardless of how many times you click on the link</div> |
|---|
| 35 | </body> |
|---|
| 36 | </html> |
|---|