|
|
(6 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| [http://en.wikipedia.org/wiki/Ajax_%28programming%29 Ajax]-driven or JavaScript-heavy sites often require | | #REDIRECT [[Capturing and Bubbling]] |
| different strategies than when scripting a regular site: elements appear, disappear and change at any time. This page contains some tips for such sites in general.
| |
| | |
| == Catch bubbling events ==
| |
| | |
| This code will tell you what element you click, unless it or some ancestor element does <code>event.stopPropagation()</code>:
| |
| | |
| document.addEventListener('click',function(event) {
| |
| GM_log("Clicked " + event.target);
| |
| }, true);
| |
| | |
| This is useful since elements you want to attach listeners to might not be in the [[DOM]] yet when the page/script loads.
| |
| | |
| {{stub}}
| |
| | |
| [[Category:Site-specific tips]]
| |
Latest revision as of 01:32, 4 February 2010
This category currently contains no pages or media.