<
From version < 18.1 >
edited by Caleb James DeLisle
on 2013/12/05
To version < 20.1 >
edited by Guillaume Delhumeau
on 2014/10/27
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.CalebJamesDeLisle
1 +XWiki.gdelhumeau
Content
... ... @@ -150,7 +150,7 @@
150 150  
151 151  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##.
152 152  
153 -== RequireJS and jQuery APIs ==
153 += RequireJS and jQuery APIs =
154 154  
155 155  By default XWiki uses PrototypeJS which is bound to the $ symbol. Starting in XWiki 5.2, you may use jQuery by //requiring// it using the [[RequireJS>>http://requirejs.org/]] AMD standard. To do this you would write your code as follows:
156 156  
... ... @@ -161,3 +161,18 @@
161 161  {{/code}}
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 +
165 += Get some informations about the current document =
166 +
167 +In your javascript's applications, you can get some (meta) informations about the current document, though an AMS module.
168 +{{code language="javascript"}}
169 +require(['xwiki-meta'], function (xm) {
170 + xm.document // get he current document (eg: Main.WebHome)
171 + xm.xwiki // get the current wiki (eg: xwiki)
172 + xm.space // get the current space (eg: Main)
173 + xm.page // get the current page name (eg: WebHome)
174 + xm.version // get the current document version (eg: 1.1)
175 + xm.restURL // get the REST url of the current doc (eg: /xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome)
176 + xm.form_token // get the current CSRF token that ou should pass to your script's to avoid CSRF attacks.
177 +});
178 +{{/code}}

Get Connected