2

I am trying to use the tag g:formRemote in grails.

In head definition:

 <g:javascript library="prototype" />

view:

<g:formRemote name="something" update="remoteDocsBlock"
                      url="[ controller: 'document',
                       action: 'search']">

      search: <input name="searchstring" type="text"></input>

      <g:actionSubmit value="Search" action="search" />

      <g:render template="/document/remoteSearchList" model="[docs:docs]" />

</g:formRemote>

<div id="remoteDocsBlock">this div is updated with the result...</div>

in my controller

def search = {
.....
render (template:'remoteSearchList', model: [docs:docs])

}

Problem

What happens: a call is made to the controller, and the entire page is replaced with the result of the controller - the template _remoteSearchList. A diffrent ajax call on the page does work. I have no idea why grails behaves like that.

Update

I have removed the "__" problem. The comment solved this question.

Update

I have isolated the Problem: JQuery. I am also using JQuery on the site. If it is removed, the ajax call works... need to find a way, to make both work.

<g:javascript library="jquery-1.4.4.min" />
<g:javascript library="jquery-ui-1.8.7.custom.min" />
<g:javascript library="jquery-server-extentions" />
M.R.
  • 1,959
  • 4
  • 24
  • 32
  • 2
    `-` is an template file marker, and you don't need to use it in your render. For file `_remoteSearchList.gsp` you have to use `render(template: 'remoteSearchList')` – Igor Artamonov Dec 19 '11 at 07:32
  • Ok, thx. This solves the "__" Problem. The submit button still replaces the entire page, and not only the div with the id"remoteDocsBlock". – M.R. Dec 19 '11 at 08:12

1 Answers1

1

Oh, seems that it's because of conflict with Prototype (bundled with Grails by default) and jQuery. Remote calls are made by Prototype lib, but if you install jQuery plugin for grails - it'll start using jquery for remote calls.

Igor Artamonov
  • 35,450
  • 10
  • 82
  • 113