tags:

views:

157

answers:

1

I am trying to list addresses and onChange event I send the address ID and return a list of users.

<g:select name="AddressID" from="${address}" optionKey="id" optionValue="address"
              onchange="${ remoteFunction(
                           action:'testMe', 
                           params:'\'id=\' + this.value' ,
                           update:'show' )}">
      </g:select>

I call this div "show".

<div id="show">
  <g:each in="${users}" status="i" var="C">
        <h3>${C}</h3>
  </g:each>

</div>

However, when I click the item on the list box I get the following error: description The requested resource (/MyTest/WEB-INF/grails-app/views/test/testMe.jsp) is not available.

My understanding of an update attribute inside a remoteFunction is that it is the name of the div which gets refreshed after the remoteFunction call is compeleted.

Thanks.

+1  A: 

I would reorganize your code a little to get the Ajax working:

  1. Move your div contents into a partial template, called, say, _remoteResponse.gsp:

    <g:each in="${users}" status="i" var="C">
    <h3>${C}</h3>
    </g:each>

  2. Modify your controller's testMe action to render the response to a template, something like:

render (template:'remoteResponse', model:[users:['mike,tim']])

  • Make sure you have an ajax library setup in main.gsp, like:

<g:javascript library="prototype" />

Mike Sickler