Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. gdelhumeau1 +XWiki.mflorea - Content
-
... ... @@ -162,6 +162,22 @@ 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 == 166 + 167 +Starting with XWiki 6.4 you can catch from jQuery the custom XWiki events that are fired from Prototype. 168 + 169 +{{code language="js"}} 170 +require(['jquery', 'xwiki-events-bridge'], function($) { 171 + $('.some-element').on('xwiki:moduleName:eventName', function(event, data) { 172 + // Here, do something that will be executed at the moment the event is fired. 173 + doSomething(); 174 + 175 + // The passed data is a reference to the event.memo from Prototype. 176 + console.log(data.somethingINeedToKnow); 177 + }); 178 +}); 179 +{{/code}} 180 + 165 165 = Get some informations about the current document = 166 166 167 167 In your javascript's applications, you can get some (meta) informations about the current document, though an AMS module. ... ... @@ -168,13 +168,13 @@ 168 168 169 169 {{code language="javascript"}} 170 170 require(['xwiki-meta'], function (xm) { 171 - xm.document // get he current document (eg: Main.WebHome) 187 + xm.document // get the current document (eg: Main.WebHome) 172 172 xm.xwiki // get the current wiki (eg: xwiki) 173 173 xm.space // get the current space (eg: Main) 174 174 xm.page // get the current page name (eg: WebHome) 175 175 xm.version // get the current document version (eg: 1.1) 176 176 xm.restURL // get the REST url of the current doc (eg: /xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome) 177 - xm.form_token // get the current CSRF token that ou should pass to your script 's to avoid CSRF attacks.193 + xm.form_token // get the current CSRF token that you should pass to your scripts to avoid CSRF attacks. 178 178 }); 179 179 {{/code}} 180 180