function ge...">

Pass in g: remoteLink as a result of javascript function

in.gsp file I have a javaScript function

<script type="text/javascript">
 function getCurrentItemNumber(){
        return document.getElementById('item_itemNumber').innerHTML.substr(6);
    }
</script>

and in g: remoteLink I like passing parameter with this function

something like the following ...

<g:remoteLink id="remove_item_button" action="removeItem" update="itemBox"
            params="[itemNumber:getCurrentItemNumber()]">- Remove Item</g:remoteLink>

How can i achieve this?

+4
source share
1 answer

AS Workaround I can suggest the following

  • change g: remoteLink to a simple link

    "<" a id = "remove_item_button" class = "btn small primary" onclick = "removeItem ();" > - Delete the element "<" / a>

  • Add a javaScript function that will send data through AJAX

    removeItem() {       $.ajax({: 'POST',           : { 'ItemNumber': getCurrentItemNumber()},           url: '$ {createLink (:' removeItem ')}',           success: function (data, textStatus) {               JQuery ( '# itemBox') HTML ().           }});   }

+1

All Articles