【发布时间】:2017-06-07 11:16:38
【问题描述】:
我想使用 el 表达式动态获取列表或数组中的所有元素。
我正在使用以下代码。如果我使用变量 isstatus 它不起作用。
${claimNotificationForm.chattels[istatus].objectValue}
下面的工作就像..
${claimNotificationForm.chattels[0].objectValue}
${claimNotificationForm.chattels[1].objectValue}
如何在此处使用变量,以便根据状态值评估 el 表达式。
下面是我使用的jsp代码。
_createAutocomplete: function() {
var x = this.element[0].id; //value is combobox-0
var status = x.substr(x.length - 1); // value is 0 which is in string
var istatus = parseInt(status); // converted to int
this.input = $( "<input>" )
.appendTo( this.wrapper )
.attr( "title", '<fmt:message key="page.claim.personalclaimnotification.injury.select_info" />' )
.val("${claimNotificationForm.chattels[0].objectValue}") //works fine with 0,1,2... I have to use 'istatus' here
.css({
color: function( index, value ) {
if (this.value == '<fmt:message key="page.claim.search.object.name" />') {
return "#777";
}
},
fontStyle: function( index, value ) {
if (this.value == '<fmt:message key="page.claim.search.object.name" />') {
return "italic";
}
},
width: "286px"
})
.attr("maxlength", 256)
.addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
.autocomplete({
delay: 0,
minLength: 3,
source: $.proxy( this, "_source" )
})
【问题讨论】:
-
我明白了。您可以尝试打印状态值并检查它是什么吗?要么使用 console.log(status);或警报(状态);我想我们会这样发现问题
-
或者您可能会问另一个关于“JSTL 核心库/EL 表达式中的方括号在 jquery 代码中不起作用”的问题。类似的东西
-
是的。会这样做。 @法拉兹
标签: javascript java jquery combobox el