Changes for page XWiki JavaScript API

Last modified by Vincent Massol on 2020/03/23

<
From version < 17.1 >
edited by Sergiu Dumitriu
on 2012/10/25
To version < 17.2 >
edited by Sergiu Dumitriu
on 2012/10/25
>
Change comment: Fixed broken code

Summary

Details

Page properties
Content
... ... @@ -24,7 +24,7 @@
24 24  
25 25  * **##xwiki:dom:loaded##**
26 26  This event is similar to [[prototype's dom:loaded event>>http://www.prototypejs.org/api/document/observe]], with the difference that in the time-lapse between ##dom:loaded## and ##xwiki:dom:loaded##, XWiki may have transformed the DOM. Example of DOM transformations operated by XWiki is setting the right target of links that have rel="external" attribute so that the document can be XHTML valid and still have the desired effect, making internal rendering error messages expandable, insert document template handlers for links to non-existent documents, and so on. In the future there might be more transformations operated by XWiki upon DOM initialization. This event is meant for code to be notified of loading of the XWiki-transformed version of the initial DOM. As ##dom:loaded##, it can be used as follows:(((
27 -{{code}}
27 +{{code language="javascript"}}
28 28  document.observe("xwiki:dom:loaded", function(){
29 29   // Initialization that can rely on the fact the DOM is XWiki-tranformed goes here.
30 30  });
... ... @@ -40,13 +40,13 @@
40 40   elements.each(function(element) {
41 41   element.select('.someBehavioralClass').each(function(item) {
42 42   enhance(item);
43 - })
44 - }
43 + });
44 + });
45 45  }
46 46  ['xwiki:dom:loaded', 'xwiki:dom:updated'].each(function(eventName) {
47 47   document.observe(eventName, function(event) {
48 48   init(event.memo && event.memo.elements || [document.documentElement]);
49 - }
49 + });
50 50  });
51 51  {{/code}}
52 52  

Get Connected