I wrote:
I'm experimenting with including some jQuery UI elements into some wiki pages using XWiki 7.1. As a test, I've been trying to get the spinner example from http://api.jqueryui.com/spinner/ to work:
I have constructed a minimal page, with content body: {{velocity}} {{html}} <input id="spinner" /> {{/html}} {{/velocity}}
And for the page I've added an objects of type XWiki.JavaScriptExtension containing code: require(['jquery'], function($) { $( "#spinner" ).spinner(); });
Vincent replied:
I’m far from a JS expert, but it seems your code is saying that it depends on jquery but not on jquery-ui and https://api.jqueryui.com/spinner/ seems to indicate that the spinner is located in jquery-ui…
Try depending on jquery-ui maybe?
Right, I'd misunderstood the purpose of require(), which I thought was to provide compatibility vs prototype when using '$'. However, this still doesn't fix things completely, but does move them forwards a bit. require(['jquery','jquery-ui'], function($) { $( "#spinner" ).spinner(); }); Now gives me "NetworkError: 404 Not Found - https://brynswiki.net/xwiki/bin/view/TestJQ/jquery-ui.js" so it's still looking in the wrong place. Do I need to be configure RequireJS to find jquery-ui.js? I see in the rendered page source require.config({ paths: { 'jquery': '/xwiki/webjars/jquery/1.11.1/jquery.min.js?r=1', 'bootstrap': '/xwiki/webjars/bootstrap/3.3.4/js/bootstrap.min.js?r=1', 'xwiki-meta': '/xwiki/resources/js/xwiki/meta', 'xwiki-events-bridge': "/xwiki/resources/js/xwiki/eventsBridge" }, [...] So jQuery gets mentioned but not jQuery-UI, even though I believe webjars for both are present in the XWiki installation (in /usr/lib/xwiki/WEB-INF/lib/ ) Thanks, Bryn