${var} 在 Select onchange 事件中没有被替换
我在渲染的模板中进行了以下选择,将 i 传递到模型中。正如大多数地方所预期的那样,${i} 被替换为 i 的值。但 ${i} 在 onchange 事件中没有被替换。
因此,
<g:select class='setTagtypeValue-class'
name='tagtype-${i}-header'
from="${org.maflt.ibidem.Tagtype.list(sort:'tagtype').groupBy{it.tagtype}.keySet()}"
value="${setTagtypeValue?.tagtype?.tagtype}"
noSelection="${['null':'Select One...']}"
onchange="${remoteFunction(action:'options', update:'tagtype-options-${i}',
params:'\'tagtype=\' + this.value +\'&i=${i}\'' )}" />
呈现为:
<select name="tagtype-0-header" onchange="jQuery.ajax({type:'POST',data:'tagtype=' + this.value +'&i=${i}', url:'/ibidem/metadataSet/options',success:function(data,textStatus){jQuery('#tagtype-options-${i}').html(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});" class="setTagtypeValue-class" id="tagtype-0-header">
<option value="null">Select One...</option>
<option value="abstract">abstract</option>
. . .
</select>
请注意,例如,名称已设置为“tagtype-0-header”,但在 onchange 中我得到了
data:'tagtype=' + this.value +'&i=${i}'
另请注意,在创建期间使用此模板时,替换发生在客户端,一切都按预期进行。因此,唯一的问题是在编辑期间,在服务器端工作时, ${i} 不会在 onchange 事件中被替换。
有什么想法吗?
I have following select in a template that I render, passing i in the model. ${i} get's replaced with the value of i, as expected in most places. But ${i} is not getting replaced in the onchange event.
So,
<g:select class='setTagtypeValue-class'
name='tagtype-${i}-header'
from="${org.maflt.ibidem.Tagtype.list(sort:'tagtype').groupBy{it.tagtype}.keySet()}"
value="${setTagtypeValue?.tagtype?.tagtype}"
noSelection="${['null':'Select One...']}"
onchange="${remoteFunction(action:'options', update:'tagtype-options-${i}',
params:'\'tagtype=\' + this.value +\'&i=${i}\'' )}" />
gets rendered as:
<select name="tagtype-0-header" onchange="jQuery.ajax({type:'POST',data:'tagtype=' + this.value +'&i=${i}', url:'/ibidem/metadataSet/options',success:function(data,textStatus){jQuery('#tagtype-options-${i}').html(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});" class="setTagtypeValue-class" id="tagtype-0-header">
<option value="null">Select One...</option>
<option value="abstract">abstract</option>
. . .
</select>
Notice that, for example, name has been set to "tagtype-0-header", but in the onchange I'm getting
data:'tagtype=' + this.value +'&i=${i}'
Also note that when this template is used during Create, where the substition happens client side, everything works as expected. So the only problem is that during Edit, working server-side, ${i} isn't getting replaced within the onchange event.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您已经位于
${}
内部,因此内部${}
将被忽略。试试这个:Since you're already inside of a
${}
, the inner${}
is going to be ignored. Try this out: