![]() Kudos to the authors of the JQuery Tagit and Grails Taggable plugins. With these very few lines of code a comfortable user interface for tagging with auto-completion could be established. The code above searches for all tags starting with the given term and returns their name as JSON. This method is particularly useful if you have a form with one input field for comma-delimited tags that you want to trivially 'upgrade' to this fancy jQuery UI widget. JQuery-UI auto-completion passes the partially entered tag in request parameter term. Example using a single input form field to hold all the tag values, instead of one per tag (see settings.singleField). For more information on this concept, checkout the docs of the Grails resources plugin. Since we’ve added resources to our project let’s declare them as a module for the resources plugin. The jQuery Tagit plugin transforms an html unordered list into a unique tagging plugin. one of tagit/css/tagit-.css and tagit/css/ui-anim_basic_16x16.gif to /web-app/css.We basically need to copy three files contained in the zip: Using the resources plugin for managing our css/js/image resources is also a good idea: grails install-plugin jquery-uiĭownload an unzip the latest version of tagit (1.5 when authoring this post) to some temporary location. gives me a dropdown with three lines for each potential match as you might expect from his code. I put some test buttons to see if it works. My goal was to give the end users the option to use a button to add a tag. Everything was going (suspiciously) smooth until I attempted to add my own wee bit of jQuery. Since the Tagit plugin depends on JQueryUI for autocompletion, lets first install this in the application. I'm using a really awesome plugin named jQuery Tagit in the development of my current project. Setting up JQuery Tagit in the Grails application import īy marking the domain class with the taggable interface it gets injected some methods for manipulating its tags on instance levelĪs well as some new methods on class level: Setting up the ‘to-be-tagged’ domain classes is fairly trivial, the only thing left is to add ‘implements Taggable’ to the ‘to-be-tagged’ domain classes, e.g. Setting up the ‘to-be-tagged’ domain classĪfter installing the taggable plugin the usual way using grails install-plugin taggable Both play together very well – showing this is the intention of this post. For the frontend side JQuery has a nice plugin called Tagit plugin caring about editing tags and auto-completion. On the application’s side, there’s the Grails Taggable plugin available. In fact there is a very simple and elegant solution for this. In order not to clutter the tagspace too much auto-complete should be available when editing the tags. ![]() In a recent Grails project the customer asked for support of a tagging functionality for some domain classes. ![]()
0 Comments
Leave a Reply. |