Quantcast

Ajax using <g:remoteLink>

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Ajax using <g:remoteLink>

loesch.greg
Reading through the Grails docs (see here Grails - Latest - #ajax), I was led to believe that I could use Ajax to update a div using the following syntax:

My view (Ajax/index.gsp)
<!doctype html>
<head>
        <meta name="layout" content="main"/>
</head>
<body>
        <div id="error"></div>
        <div id="message"></div>
        <g:remoteLink action="retrievePets" update="message">Ajax magic... Click here</g:remoteLink>
</body>
</html>

My controller (AjaxController):
package genericsite

class AjaxController {

    def index() { }

        def retrieveMessage() {
                render "Weeee! Ajax!"
        }
}

However, when I select the link, it just sends me to a page with "Weeee! Ajax!"

I know how to do this the typical jQuery way (which I'm pretty sure this technique essentially uses)... just wondered what I was doing wrong. Looks convenient.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Ajax using <g:remoteLink>

Ian Roberts
On 03/08/2012 21:50, loesch.greg wrote:
> However, when I select the link, it just sends me to a page with "Weeee!
> Ajax!"

You need to add

<r:require module="jquery"/>

to the <head> section of your GSP in order to load the javascript
library that makes <g:remoteLink> work.

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Ajax using <g:remoteLink>

loesch.greg
Awesome. Thanks for the quick response (here and StackOverflow)!

On Aug 3, 2012, at 6:17 PM, Ian Roberts [via Grails] <[hidden email]> wrote:

On 03/08/2012 21:50, loesch.greg wrote:
> However, when I select the link, it just sends me to a page with "Weeee!
> Ajax!"

You need to add

<r:require module="jquery"/>

to the <head> section of your GSP in order to load the javascript
library that makes <g:remoteLink> work.

Ian

--
Ian Roberts               | Department of Computer Science
<a href="x-msg://18/user/SendEmail.jtp?type=node&amp;node=4632697&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/Ajax-using-g-remoteLink-tp4632695p4632697.html
To unsubscribe from Ajax using <g:remoteLink>, click here.
NAML

Loading...