loading an script from sub directory url

70 views
Skip to first unread message

José F. Romaniello

unread,
Nov 25, 2012, 10:30:50 AM11/25/12
to ja...@googlegroups.com

I have a few modules installed, with requirejs, and i have a file:

define(['moment'], function(moment){
  alert(moment());
});

this file is in :

http://xx/js/usecase.js

And I am loading from: http://xx/usecase/yadayada

as follows:

require(["/js/usecase.js"], function (m){})

It fails because require.js try to loads moment from:

http://xx/usecase/jam/moment/moment.js

instead of:

http://xx/jam/moment/moment.js

how can i fix this?


thanks


Caolan McMahon

unread,
Nov 25, 2012, 12:58:34 PM11/25/12
to ja...@googlegroups.com

Have a look at the baseUrl config option for RequireJS:
http://requirejs.org/docs/api.html#config-baseUrl
> --
> You received this message because you are subscribed to the Google Groups "jamjs" group.
> To post to this group, send an email to ja...@googlegroups.com.
> To unsubscribe from this group, send email to jamjs+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msg/jamjs/-/Dh3eLkMdo4UJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

José F. Romaniello

unread,
Nov 25, 2012, 2:49:13 PM11/25/12
to ja...@googlegroups.com
Hi thanks!, it works if i add this: baseUrl: "/" to my RequireJs configuration file, but in my project this file is generated everytime by jamjs and it is not under source control

whats the best place to put this?

thanks


2012/11/25 Caolan McMahon <caolan....@gmail.com>

Have a look at the baseUrl config option for RequireJS:
http://requirejs.org/docs/api.html#config-baseUrl
Reply all
Reply to author
Forward
0 new messages