On 12 Aug 2015 at 22:31:11, vincent(a)massol.net
(vincent@massol.net(mailto:vincent@massol.net)) wrote:
Hi Bryn,
On 12 Aug 2015 at 22:05:25, Bryn Jeffries
(bryn.jeffries@sydney.edu.au(mailto:bryn.jeffries@sydney.edu.au)) wrote:
Vincent suggested:
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();
});
Actually, more playing around eventually gave me this, which does work:
require(['jquery',"$services.webjars.url('jquery-ui',
'jquery-ui.js')"], function($) {
$( "#spinner" ).spinner();
});
I wouldn't say I'm 100% sure of what I'm doing with require, or if this is
the best way to do it, but at least it works without errors.
That looks correct. The reason you could simply use “jquery” in the require() function is
because it’s declared in javascript.vm:
require.config({
paths: {
'jquery': '#removeJsSuffix($services.webjars.url("jquery",
"jquery${jsExtension}"))',
'bootstrap': '#removeJsSuffix($services.webjars.url("bootstrap",
"js/bootstrap${jsExtension}"))',
'xwiki-meta':
'$stringtool.removeEnd($xwiki.getSkinFile('js/xwiki/meta.js'),
'.js')',
'xwiki-events-bridge':
"$stringtool.removeEnd($xwiki.getSkinFile('js/xwiki/eventsBridge.js'),
'.js')"
},
…
This is not the case for jquery-ui or for other webjars. This is why you need to use
$services.webjars.url(..).
Would be great if you could help us and add this information on
http://platform.xwiki.org/xwiki/bin/view/DevGuide/FrontendResources :)
If you don’t have the time, I’ll do it when I’m back from holidays (still on holidays for
the coming 4 days :)).
errr…. 11 days… :)
-Vincent