From version < 7.2 >
edited by Ecaterina Moraru (Valica)
on 2010/11/04
To version < 9.1 >
edited by Sergiu Dumitriu
on 2010/11/06
< >
Change comment: Document converted from syntax xwiki/1.0 to syntax xwiki/2.0

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.evalica
1 +XWiki.Sergiu
Syntax
... ... @@ -1,1 +1,1 @@
1 -XWiki 1.0
1 +XWiki 2.0
Content
... ... @@ -1,16 +1,22 @@
1 +{{velocity filter="none"}}
2 +{{html clean="false" wiki="true"}}
1 1  #startfloatingbox()
2 -*Contents:*
3 -#toc("" "" "")
4 +**Contents:**
5 +
6 +{{toc start="" depth="" numbered=""/}}
4 4  #endfloatingbox()
5 -1 XWiki JavaScript API
8 +{{/html}}
9 +{{/velocity}}
6 6  
7 -1.1 Observable XWiki Events
11 += XWiki JavaScript API =
8 8  
13 +== Observable XWiki Events ==
14 +
9 9  Stay in touch with what happens in the wiki! XWiki will fire custom javascript events on certain moment and upon certain actions that occur in the navigation flow.
10 10  
11 -Event names are build on the following model: <tt>xwiki:modulename:eventname</tt>. Your JavaScript script or extension can get notified of such an event the following way:
17 +Event names are build on the following model: ##xwiki:modulename:eventname##. Your JavaScript script or extension can get notified of such an event the following way:
12 12  
13 -{code}
19 +{{code}}
14 14  document.observe("xwiki:modulename:eventname", function(event){
15 15   // Here, do something that will be executed at the moment the event is fired
16 16   doSomething();
... ... @@ -17,51 +17,51 @@
17 17  
18 18   // The event can have an option memo object to pass to its observers some information:
19 19   console.log(event.memo.somethingINeedToKnow);
20 -});
21 -{code}
26 +});
27 +{{/code}}
22 22  
23 -Check out the real examples below, or [read more>http://prototypejs.org/api/element/fire] about Prototype.js's event system
29 +Check out the real examples below, or [[read more>>http://prototypejs.org/api/element/fire]] about Prototype.js's event system
24 24  
25 -1.1.1 DOM Events (xwiki.js)
31 +=== DOM Events (xwiki.js) ===
26 26  
27 -* *<tt>xwiki:dom:loading</tt>*
28 -* *<tt>xwiki:dom:loaded</tt>*
33 +* **##xwiki:dom:loading##**
34 +* **##xwiki:dom:loaded##**
29 29  
30 -These events are similar to [prototype's dom:loaded event>http://www.prototypejs.org/api/document/observe], with the difference that in the time-lapse between <tt>dom:loaded</tt> and <tt>xwiki:dom:loaded</tt>, 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. 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 <tt>dom:loaded</tt>, it can be used as follow:
36 +These events are 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. 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 follow:
31 31  
32 -{code}
38 +{{code}}
33 33  document.observe("xwiki:dom:loaded", function(){
34 34   // Initialization that can rely on the fact the DOM is XWiki-tranformed goes here.
35 35  });
36 -{code}
42 +{{/code}}
37 37  
38 -*It is recommended to bind startup scripts to this event* instead of <tt>window.load</tt> or <tt>document.dom:loaded</tt>.
44 +**It is recommended to bind startup scripts to this event** instead of ##window.load## or ##document.dom:loaded##.
39 39  
40 -<tt>xwiki:dom:loading</tt> is sent between <tt>dom:loaded</tt> and <tt>xwiki:dom:loaded</tt>, before XWiki changes the DOM. This is the event that should start all scripts making important DOM changes that other scripts should see.
46 +##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.
41 41  
42 -1.1.1 Document content events (actionButtons.js)
48 +=== Document content events (actionButtons.js) ===
43 43  
44 -* *<tt>xwiki:document:saved</tt>*
50 +* **##xwiki:document:saved##**
45 45  
46 -This is event is sent after the document has been successfully saved in an asynchronous request (i.e. after clicking the ~~Save and Continue~~ button).
52 +This is event is sent after the document has been successfully saved in an asynchronous request (i.e. after clicking the //Save and Continue// button).
47 47  
48 -* *<tt>xwiki:document:saveFailed</tt>*
54 +* **##xwiki:document:saveFailed##**
49 49  
50 -1.1.1 Action events (actionButtons.js)
56 +=== Action events (actionButtons.js) ===
51 51  
52 -* *<tt>xwiki:actions:cancel</tt>*
58 +* **##xwiki:actions:cancel##**
53 53  
54 54  This event is sent after the user clicks the "Cancel" button of an editor (Wiki, WYSIWYG, object, rights, etc.), but before actually cancelling the edit.
55 55  
56 -* *<tt>xwiki:actions:preview</tt>*
62 +* **##xwiki:actions:preview##**
57 57  
58 58  This event is sent after ther use clicks the "Preview" button of an editor (Wiki, WYSIWYG, object, rights, etc.), but before actually leaving the edit mode.
59 59  
60 -* *<tt>xwiki:actions:save</tt>*
66 +* **##xwiki:actions:save##**
61 61  
62 -This event is sent after the user clicks the "Save" or "Save & Continue" button of an editor (Wiki, WYSIWYG, object, rights, etc.), but before actually submitting the form. A memo is available if you need to know if the intend is to continue after the save, in <tt>event.memo.continue</tt>. You can use it as follows:
68 +This event is sent after the user clicks the "Save" or "Save & Continue" button of an editor (Wiki, WYSIWYG, object, rights, etc.), but before actually submitting the form. A memo is available if you need to know if the intend is to continue after the save, in ##event.memo.continue##. You can use it as follows:
63 63  
64 -{code}
70 +{{code}}
65 65  document.observe("xwiki:dom:loaded", function(event){
66 66   var doContinue = event.memo.continue;
67 67   if (doContinue) {
... ... @@ -68,17 +68,17 @@
68 68   // do something specific
69 69   }
70 70  });
71 -{code}
77 +{{/code}}
72 72  
73 73  All these events contain as extra information, in the second parameter sent to event listeners (the memo), the original click event (if any, and which can be stopped to prevent the action from completing), and the form being submitted.
74 74  
75 -1.1.1 Document extra events (xwiki.js)
81 +=== Document extra events (xwiki.js) ===
76 76  
77 -* *<tt>xwiki:docextra:loaded</tt>*
83 +* **##xwiki:docextra:loaded##**
78 78  
79 79  This event is fired upon reception of the content of a document footer tab by AJAX. This event is useful if you need to operate transformations of the received content. You can filter on which tab content to operate (comments or attachment or information or ...) using the event memo. The DOM element in which the retrieved content has been injected is also passed to facilitate transformations.
80 80  
81 -{code}
87 +{{code}}
82 82  document.observe("xwiki:docextra:loaded", function(event){
83 83   var tabID = event.memo.id;
84 84   if (tabID == "attachments") {
... ... @@ -86,32 +86,38 @@
86 86   doSomething(event.memo.element);
87 87   }
88 88  });
89 -{code}
95 +{{/code}}
90 90  
91 -* *<tt>xwiki:docextra:activated</tt>*
97 +* **##xwiki:docextra:activated##**
92 92  
93 -This event is fired upon activation of a tab. It differs from the loaded event since tabs are loaded only once if the user clicks going back and forth between tabs. This event will notify of each tab activation, just after the tab content is actually made visible. The tab ID is passed in the memo as for <tt>xwiki:docextra:loaded</tt>
99 +This event is fired upon activation of a tab. It differs from the loaded event since tabs are loaded only once if the user clicks going back and forth between tabs. This event will notify of each tab activation, just after the tab content is actually made visible. The tab ID is passed in the memo as for ##xwiki:docextra:loaded##
94 94  
95 -1.1.1 WYSIWYG events (XWikiWysiwyg.js)
101 +=== WYSIWYG events (XWikiWysiwyg.js) ===
96 96  
97 -WYSIWYG has it's own custom [events list>http://code.xwiki.org/xwiki/bin/view/Modules/WysiwygEditorModule#HCustomevents].
103 +WYSIWYG has it's own custom [[events list>>http://code.xwiki.org/xwiki/bin/view/Modules/WysiwygEditorModule#HCustomevents]].
98 98  
99 -1.1.1 Fullscreen events (fullScreenEdit.js) (since 2.5.1)
105 +=== Suggest events (ajaxSuggest.js) ===
100 100  
101 -* *<tt>xwiki:fullscreen:entered</tt>*
102 -* *<tt>xwiki:fullscreen:exited</tt>*
103 -* *<tt>xwiki:fullscreen:resized</tt>*
107 +* **##xwiki:suggest:selected##** (since 2.3)
104 104  
105 -1.1.1 Annotations events (AnnotationCode/Settings jsx)
109 +This event is fired when a value was selected
106 106  
107 -* *<tt>xwiki:annotations:filter:changed</tt>*
108 -* *<tt>xwiki:annotations:settings:loaded</tt>*
111 +=== Fullscreen events (fullScreenEdit.js) (since 2.5.1) ===
109 109  
110 -1.1.1 Livetable events (livetable.js)
113 +* **##xwiki:fullscreen:entered##**
114 +* **##xwiki:fullscreen:exited##**
115 +* **##xwiki:fullscreen:resized##**
111 111  
112 -* *<tt>xwiki:livetable:newrow</tt>*
113 -* *<tt>xwiki:livetable:loadingEntries</tt>* (since 2.3 RC1)
114 -* *<tt>xwiki:livetable:receivedEntries</tt>* (since 2.3 RC1)
115 -* *<tt>xwiki:livetable:loadingComplete</tt>* (since 2.4 M1)
116 -* *<tt>xwiki:livetable:displayComplete</tt>* (since 2.4 M1)
117 -* *<tt>xwiki:livetable:ready</tt>* (since 2.4.4)
117 +=== Annotations events (AnnotationCode/Settings jsx) ===
118 +
119 +* **##xwiki:annotations:filter:changed##**
120 +* **##xwiki:annotations:settings:loaded##**
121 +
122 +=== Livetable events (livetable.js) ===
123 +
124 +* **##xwiki:livetable:newrow##**
125 +* **##xwiki:livetable:loadingEntries##** (since 2.3 RC1)
126 +* **##xwiki:livetable:receivedEntries##** (since 2.3 RC1)
127 +* **##xwiki:livetable:loadingComplete##** (since 2.4 M1)
128 +* **##xwiki:livetable:displayComplete##** (since 2.4 M1)
129 +* **##xwiki:livetable:ready##** (since 2.4.4)

Get Connected