1

I have two domains (models) Job and Results. The Job page that lists jobs that have run and the Results page lists the results of the job.

What I want to do is combine these two pages so that the user stays on the one page.

My solution was to use remoteFunction, and I am close but am stuck on getting the data back from Grails. The code below calls my controller (method doit) and it returns a Groovy List:

...  
<g:render template="resulttable" />
<button id=show>show()</button>
<script type="text/javascript">
$("#show").click(function () {
  // Returns Groovy List
  var results = <g:remoteFunction action="doit" id="${idx}" update="showit"/>  
  $(".resulttable").show('slow');
});

I am not a whiz with jQuery, so how do I process this results list? I have tried a half dozen different things and am stumped. I have a partial resulttable where I want to dislay the results. Or am I out in left field with this approach?

1 Answer 1

1

I don't think you necessarily need to use jQuery directly to do this. You could set up your gsp like this:

<g:remoteLink action="doit" id="${idx}" update="showit"><button>show()</button></g:remoteLink>
<div id="showit">
</div>

And then in your controller you doit action:

def doit = {
    //find your list here
    def yourList = ...
    render(template: "resulttable", model: [listInTemplate: yourList])
}
Sign up to request clarification or add additional context in comments.

1 Comment

I don't know what I was doing wrong, but this was not working for me yesterday. Tackled this again, and it worked - yea!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.