Drozzy
Drozzy

Reputation: 71

How to request JQuery array in Liferay velocity template variable

I have this code in .vm file

<script...>
.....
var attr = attr0[i].id;
</script....>

#set($attr1 = $request.getParameter("attr"))
$attr1

How to get the jquery attribute (which is clientside) to velocity template variable which is serverside?

Upvotes: 1

Views: 196

Answers (1)

Marco Mercuri
Marco Mercuri

Reputation: 1127

As I suggested in my comment you can use a parameter, something like this:

  1. In your template get the entire current URL (URL + parameter)
  2. Check for your parameter (es. attr)
    1. If ther is the attr parameter and it has a value do something in your template
  3. In your script create a variable with your current URL and append your parameter to it (es. var url = {$currentURL} + '?attr=attrValue')
  4. Now you have just to call this URL.

Upvotes: 0

Related Questions