Grails application context in javascript library

grails

Solution

You can pass it to Javascript as global JS variable, put this inside `<head>` tag:

<g:javascript>
   window.appContext = '${request.contextPath}';
</g:javascript>

and use it anywhere from plain javascript, like:

$.ajax({
   url: appContext + '/hello/world'
})

Problem

Is it possible to access ``` grails.app.context ``` from within a javascript library? --That is, not javascript inserted in a GSP file. I have som javascripts that are context dependent, why I need to be able to access this from javascript. I include the javascript in my gsp-files with: ``` <r:require modules="myModule" /> ```

Original source