开发者

Grails Select tag: adding styles to specific opitions

开发者 https://www.devze.com 2023-03-27 23:14 出处:网络
Hi I am trying to make a dynamically created drop down list in grails that emphasizes only certain option tags. Here is what I have:

Hi I am trying to make a dynamically created drop down list in grails that emphasizes only certain option tags. Here is what I have:

<g:select class="DropDownList"
    from="${listOfMaps}" 
    optionValue="${{(it.match=='Something'?'<em>':'') + it.thingToPrint
    + (it.match=='Something'?'</em>':'') }}" 
    />

and this 开发者_如何学Goworks in the sense that it will print the thing to print, but when it is suppose to add the <em> tag it prints it like this:

<option>&lt;em&gt;ITEM&lt;/em&gt;</option>

And that is not what I need. that prints <em>ITEM</em> in the drop down list.

Does anyone know how to get it to be this instead:

<option><em>ITEM</em></option>

so that it will print 'ITEM' ?

The resources that I have used thus far:

  • http://grails.org/doc/1.0.x/ref/Tags/select.html
  • http://jira.grails.org/browse/GRAILS-2988


The <g:select/> tag html encodes values returned from the optionValue attribute, that is why your html is getting escaped.

The best way to do this is to write a custom taglib, however, even then you'll probably want to do this with CSs instead of markup since CSS styling of an <option> tag is probably more broadly supported.

0

精彩评论

暂无评论...
验证码 换一张
取 消