jquery - Grails g:formRemote auto-retrieve -


I have this problem in my visual field in which I have this & lt; G: select & gt; The tag is a on change attribute to retrieve the referenced data of the selected value of the tag. Unfortunately, we did not accept and & lt; G: formRemote & gt; inside & lt; G: select & gt; to explain the data so that the data will be recovered through the URI of the & lt; G: formRemote & gt; to refresh the page without

  & lt ;! - G: See Remote of the form - & gt; & Lt; G: formRemote name = "formRemote" Yuri: [Controller: 'test', verb: 'function call'] & gt; & Lt; G: name = "selectedValue" = "$ {['aa', 'b' '}}" & gt; $ {ReturnData} & lt; / G: formRemote & gt; // To close the form where the remote will be called [testController.functionCall] def functionCall () {println 'enter' def returnData = 'if (params.value ==' aa ') returnData =' aaa 'else if (params. Value == 'BB') Return Data = 'BBB' [Data: ReturnData]}   

The problem is that we can not find any way to get the model data back from the controller & Lt; G: select & gt; With the change in the value of with reference to & lt; G: formRemote & gt; ].

Your selection tag should not be contained within a form. The remote tag, a regular function with a remote function call Tags from

GP:

  & lt; Form & gt; & Lt; G: option = "$ {country.list ()}" fromchange = "$ {remoteFunction (controller:" option ") Select option =" id "option = value =" name "name =" country.name "id = 'Country.name' 'country', action: 'ajaxgatecity', params: '\\' id = \\ '+ escape (this.value)' on, full: 'Update City (e)'}} '& gt; & Lt; / g: Select & gt; & lt; g: Select name = "city" id = "city"> gt; & lt; / g: select & gt; & lt; / form & gt;   

Javascript function in GSP to send data to the grille controller:

  & lt; g: javascript & gt; function updates Returns as RT (E) {// response bunch-o-JSON var cities = eval ("(+ + e.responsetext +") "). // Evaluate JSON (cities) {var rselect = document GetElementById ('city') // Clear all previous options var l = rselect.length while (l> 0) {l-- rselect.remove ( L}} // (var i = 0; i cities; long; i ++) {var city = city [i] var opt = document.createElement ('option'); Opt.text = city.name opt.value = city.id {rselect.add (opt, blank) // follow the standards; IE} (formerly) {rselect.add (opt) // IE only}}}} // It is said that when the city is loaded to start the city zselect = document.getElementById ("Country.name"), "Updatecity (e)"), but "integer": "'id =' + zopt.value" on "integer" = "+ zopt.value"} & lt; / G: javascript & gt;   

grails controller:

  import grails.converters. * Category Country Controller {def ajaxGetCities = {def country = Country.get (params.id) Country render JSON}} as    

Comments