Changes for page XWiki JavaScript API

Last modified by Simon Urli on 2022/09/14

<
From version < 23.2 >
edited by Eduard Moraru
on 2015/03/25
To version < 24.1 >
edited by Marius Dumitru Florea
on 2015/05/04
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.enygma
1 +XWiki.mflorea
Content
... ... @@ -162,7 +162,7 @@
162 162  
163 163  The best part is, any scripts which are loaded using require are loaded //asynchronously// (all at the same time) and if they are not required, they are never loaded at all.
164 164  
165 -== Bridging custom XWiki events from Prototype to jQuery ==
165 +== Bridging custom XWiki events between Prototype and jQuery ==
166 166  
167 167  Starting with XWiki 6.4 you can catch from jQuery the custom XWiki events that are fired from Prototype.
168 168  
... ... @@ -178,6 +178,22 @@
178 178  });
179 179  {{/code}}
180 180  
181 +Starting with XWiki 7.1M1 the event listeners registered from Prototype are notified when a custom XWiki event is fired using the jQuery API. This doesn't mean you should write new event listeners using Prototype but that you can rely on existing event listeners until they are rewritten using jQuery.
182 +
183 +{{code language="js"}}
184 +// Prototype (old code that you don't have time to rewrite)
185 +document.observe('xwiki:dom:updated', function(event) {
186 + event.memo.elements.each(function(element) {
187 + // Do something.
188 + });
189 +});
190 +...
191 +// jQuery (new code)
192 +require(['jquery', 'xwiki-events-bridge'], function($) {
193 + $(document).trigger('xwiki:dom:updated', {'elements': $('.some-container').toArray()});
194 +});
195 +{{/code}}
196 +
181 181  = Get some information about the current document =
182 182  
183 183  In your javascript's applications, you can get (meta) information about the current document, though an AMS module.

Get Connected