Skip to content Skip to sidebar Skip to footer

How To Incorporate A G:link Into An Ordinary Button?

In my grails application there is a view with a a g:link tag - it works fine, but the visuals are kind of awkward. Therefore, I want to disguise that g:link with an ordinary button

Solution 1:

g:link tag does nothing but at the end creates the anchor tag. So anything that you can put inside anchor tag, so with g:link.

You can simply write. <g:link class="create" action="create"><input type="button" /></g:link>

It appears to be a button to user but does the job of g:link tag.

Solution 2:

Amit Jain's answer worked but had some problems in ie 8 & 7 (looked like some kind of style overlapping error). This solution worked in all browsers I tested

<buttonclass="class"onClick="window.location = 'www.location.com' "><g:messagecode="share.learnmore"></g:message></button>

Solution 3:

I think you'll need to use some javascript on the button and the javascript onClick method to perform the linking. A good alternative is to make a nice looking image instead.

If you want to avoid javascript then just use a form with method GET

Not really grails specific but you can probably do it quite easily with g:form somehow (I'm only just getting started with Grails myself)

EDIT: Re-reading your post, the most important thing to note is that I used input type="submit" which calls the action field in the form rather than just being a button.

Solution 4:

I think using the link and button will actually cause the button to fire twice !! Not recomended if you are doing some work off the back of it ..

Post a Comment for "How To Incorporate A G:link Into An Ordinary Button?"