Use autocomplete input on Play! views
For source parameter (view)
source: function( req, response ) {
$.getJSON( "@routes.Controller.auto("")" + extractLast( req.term ), { term: extractLast( req.term ) }, response );
}
On your controller class, create static method that accept the term: String parameter and return Json.
import org.codehaus.jackson.node.ObjectNode;
import play.libs.Json;
@BodyParser.Of(play.mvc.BodyParser.Json.class)
public static Result auto(String term) {
ObjectNode result = Json.newObject();
//populate with correct suggestions
return ok(result);
}
Written by Hendra Gunawan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#