Last updated by admin 1 year ago
grails install-plugin javascript-url-mappings
Last updated by dan_lynn 1 year ago
A Grails plugin to provide client-side reverse URL mappings outside of GSP files.
Just put one taglib call in your layout and your static javascript files can make use of Grails' UrlMappings
Example usage (jQuery)
<!-- Place this tag in your layout's head element: -->
<g:urlMappings /> <script type="text/javascript">
var url = g.createLink({controller: 'news', action: 'fetch', params: {since: new Date()}});
$('#myDiv').load(url); var img = document.createElement('img');
img.src = g.resource({dir: 'images', file: 'icon.gif'}); </script>More usage examples can be found in the javascript unit tests:
http://github.com/danklynn/grails-javascript-url-mappings/blob/0.1/grails-app/views/index.gspCurrent Status
Currently reverse-maps all controllers and actions, using the params
controller ,
action , and optionally
id . Supports building static resource URLs through use of the
g.resource() function, using the params
dir and
file just like the built-in Grails taglib.
Recent Changes
- 0.1.1 - Bugfix release, fixed bad template path
- 0.1 - initial release
TODOs
- Get project under jvm-level test
- Get project under functional test to test javascript from "grails test-app"
- Add support for named mappings
- Add support for mapping wildcards to reverse-map params (e.g. "controller/action?/id?")
- Support the "url" attribute of createLink
- Support absolute urls
Contributors
Last updated by admin 1 year ago
Last updated by admin 1 year ago