How to include g: link in a regular button?

My grails app has a view with the g:link tag - it works great, but the visual effects are awkward. So I want to mask that g:link with a regular button.

I tried span class and input type="button" , but that didn't help.
Side note : I do not want g:form with the submit action.

Any help really appreciated!

+4
source share
4 answers

Amit Jane's answer worked, but had some problems, i.e. 8 and 7 (looked like some kind of style overlap error). This solution worked in all browsers I tested.

 <button class="class" onClick="window.location = 'www.location.com' "> <g:message code="share.learnmore"></g:message> </button> 
+1
source

g: The link tag does nothing, and in the end creates an anchor tag. So, everything that you can put inside the anchor tag, so with g: link.

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

This seems to be a button for the user, but does the job of the g: link tag.

+8
source

I think you will need to use javascript on the button and the javascript onClick method to execute the link. A good alternative is to create a beautiful image instead.

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

It's not really scary, but you can do it quite easily with g: form somehow (I'm just starting with Grails itself)

EDIT: After re-reading the message, the most important thing to note is that I used the input type = " submit ", which calls the action field in the form, not just a button.

+1
source

I think that using a link and a button, the button will actually fire twice! Not recommended if you are doing any work outside of it.

+1
source

All Articles