Adam Carlin
Adam Carlin

Reputation: 244

Adding g:select tag through jquery

I'm trying to add g:select tags dynamically through a jquery function I have written. I know the function works as I use it elsewhere in the project to add a normal html element. The variable im trying to add is

                 var row ='<tr class="prop"> <td valign="top" style="text-alight:left;" width="20%"> <label for="batsmanHome' + rowNum + '"> Batsman: </label> </td> <td valign="top" style="text-alight:left;" width="20%"> <g:select name="batsmanHome"' + rowNum + '" from="${fixtureInView.homeTeam.players.asList()}" optionKey="id"/> </td> <td valign="top" style="text-align:left;" width="20%"> <input onclick="addRowHome(this.form);" type="button" value="Add Player" /> </td></tr>'

This comes up wit the error illegal colon after argument expression; solution: a complex label expression before a colon must be parenthesized @ line 20, column 116. Home" },'' + rowNum + '" from':evaluate( ^ which I can't get my head around. Does anyone have any ideas?

Upvotes: 0

Views: 309

Answers (1)

Alexander Suraphel
Alexander Suraphel

Reputation: 10633

<g:select needs to be processed on the server side before it is converted to a regular select tag that the browser and front end languages like javascript can understand and manipulate.

You should change your code to:

                 var row ='<tr class="prop"> <td valign="top" style="text-alight:left;" width="20%"> <label for="batsmanHome' + rowNum + '"> Batsman: </label> </td> <td valign="top" style="text-alight:left;" width="20%"> <select name="batsmanHome"' + rowNum + '"  ></select> </td> <td valign="top" style="text-align:left;" width="20%"> <input onclick="addRowHome(this.form);" type="button" value="Add Player" /> </td></tr>'

Upvotes: 1

Related Questions