Changes for page XWiki JavaScript API

Last modified by Simon Urli on 2022/09/14

<
From version < 13.1 >
edited by Marius Dumitru Florea
on 2011/02/19
To version < 15.1 >
edited by Denis Gervalle
on 2011/07/01
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.mflorea
1 +XWiki.dgervalle
Content
... ... @@ -29,10 +29,21 @@
29 29   // Initialization that can rely on the fact the DOM is XWiki-tranformed goes here.
30 30  });
31 31  {{/code}})))
32 +
32 32  **It is recommended to bind startup scripts to this event** instead of ##window.load## or ##document.dom:loaded##.
33 33  * **##xwiki:dom:loading##**
34 34  ##xwiki:dom:loading## is sent between ##dom:loaded## and ##xwiki:dom:loaded##, before XWiki changes the DOM. This is the event that should start all scripts making important DOM changes that other scripts should see.
35 35  
37 +{{warning}}
38 +If your script is loaded **deferred**, all these events may be triggered **before your script is executed** and therefore **before it has the ablity to observe these events**. Since 3.1.1, to prevent your handler to never being called, never use ##dom:loaded## anymore, and check ##XWiki.isInitialized## before waiting for ##xwiki:dom:loading##, and ##XWiki.domIsLoaded## before waiting for ##xwiki:dom:loaded##. If the flag is true, you should proceed immediately with your handler. Here is a simple construct to properly handle this:(((
39 +{{code}}
40 +function init() {
41 + // This is your initialization handler, that you generally hook to xwiki:dom:loaded
42 +}
43 +(XWiki && XWiki.domIsLoaded && init()) || document.observe("xwiki:dom:loaded", init);
44 +{{/code}})))
45 +{{/warning}}
46 +
36 36  === Document content events (actionButtons.js) ===
37 37  
38 38  * **##xwiki:document:saved##**
... ... @@ -87,13 +87,13 @@
87 87  * **##xwiki:suggest:selected##** (since 2.3)
88 88  This event is fired on the target input when a value was selected.
89 89  
90 -=== Fullscreen events (fullScreenEdit.js) (since 2.5.1) ===
101 +=== Fullscreen events (fullScreenEdit.js) ===
91 91  
92 -* **##xwiki:fullscreen:enter##** fired before entering full screen editing (since 3.0M3)
93 -* **##xwiki:fullscreen:entered##** fired after entering full screen editing
94 -* **##xwiki:fullscreen:exit##** fired before exiting full screen editing (since 3.0M3)
95 -* **##xwiki:fullscreen:exited##** fired after exiting full screen editing
96 -* **##xwiki:fullscreen:resized##**
103 +* **##xwiki:fullscreen:enter##** (since 3.0 M3) (fired before entering full screen editing)
104 +* **##xwiki:fullscreen:entered##** (since 2.5.1) (fired after entering full screen editing)
105 +* **##xwiki:fullscreen:exit##** (since 3.0 M3) (fired before exiting full screen editing)
106 +* **##xwiki:fullscreen:exited##** (since 2.5.1) (fired after exiting full screen editing)
107 +* **##xwiki:fullscreen:resized##** (since 2.5.1)
97 97  
98 98  All events have the target DOM element in ##event.memo.target##.
99 99  
... ... @@ -110,5 +110,6 @@
110 110  * **##xwiki:livetable:loadingComplete##** (since 2.4 M1) (##event.memo.status## contains the response status code)
111 111  * **##xwiki:livetable:displayComplete##** (since 2.4 M1)
112 112  * **##xwiki:livetable:ready##** (since 2.4.4)
124 +* **##xwiki:livetable:loading##** (since 3.1.1) (should be used in place of ##xwiki:dom:loading## to startup livetables)
113 113  
114 114  The livetable sends both generic events, named as above, and events specific to each livetable, containing the table name on the third position, such as ##xwiki:livetable:alldocs:loadingEntries##. The generic event has the table name in the memo, as ##event.memo.tableId##.

Get Connected