Change comment:
document availability of requirejs/jquery
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. ManuelSmeria1 +XWiki.CalebJamesDeLisle - Content
-
... ... @@ -149,3 +149,15 @@ 149 149 * **##xwiki:livetable:loading##** (since 3.1.1) (should be used in place of ##xwiki:dom:loading## to startup livetables) 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 + 153 +== RequireJS and jQuery APIs == 154 + 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 + 157 +{{code language="javascript"}} 158 +require(['jquery'], function ($) { 159 + $('#xwikicontent').append('<p>Inside of this function, $ becomes jquery!</p>'); 160 +}); 161 +{{/code}} 162 + 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.