SaDman_SUT
SaDman_SUT

Reputation: 177

Pass Javascript Variable into taglib method call Grails

any idea for this

var elemVal = $("#element").val();
var finalVal = "${someTagLib(attr: elemVal)}";

The element is a select option, so I am getting the value that the user selected to pass into a taglib function. It seems that search isn't being passed into the taglib. Anyone have a suggestion?

Upvotes: 0

Views: 734

Answers (1)

Shashank Agrawal
Shashank Agrawal

Reputation: 25797

This is not possible at all. You are trying to mix server side code with client side code which is a common mistake.

When you use gsp's they first compiled on server i.e. in JVM, but there javascript can not be executed. Similarly when compiled gsp content is rendered as html in the browser, there will be no ${} since that is an groovy expression.

So the thing you are trying to achieve is not possible.

Upvotes: 1

Related Questions