【发布时间】:2014-06-23 09:43:36
【问题描述】:
我在 Razor 视图页面上有几个 Kendo NumericTextBoxes 和一个事件处理程序:
@Html.Kendo().NumericTextBoxFor(model => model.SignedNumericTextBox1).Step(0.25f).Events(e => e.Change("ChangeSignedNumericTextBox1"))
@Html.Kendo().NumericTextBoxFor(model => model.SignedNumericTextBox2).Step(0.25f).Events(e => e.Change("ChangeSignedNumericTextBox2"))
@Html.Kendo().NumericTextBoxFor(model => model.SignedNumericTextBox3).Step(0.25f).Events(e => e.Change("ChangeSignedNumericTextBox3"))
<script>
function ChangeSignedNumericTextBox1() {
var val = this.value()
alert(this.name);
if (val > 0) {
$("#SignedNumericTextBox1").kendoNumericTextBox({ format: "+##.##", decimals: 2 });
}
else {
$("#SignedNumericTextBox1").kendoNumericTextBox({ format: "##.##", decimals: 2 });
}
}
function ChangeSignedNumericTextBox2() {
var val = this.value()
alert(this.name);
if (val > 0) {
$("#SignedNumericTextBox2").kendoNumericTextBox({ format: "+##.##", decimals: 2 });
}
else {
$("#SignedNumericTextBox2").kendoNumericTextBox({ format: "##.##", decimals: 2 });
}
}
function ChangeSignedNumericTextBox3() {
var val = this.value()
alert(this.name);
if (val > 0) {
$("#SignedNumericTextBox3").kendoNumericTextBox({ format: "+##.##", decimals: 2 });
}
else {
$("#SignedNumericTextBox3").kendoNumericTextBox({ format: "##.##", decimals: 2 });
}
}
</script>
有没有办法在我的 JavaScript 中引用数字文本框,这样我只需要一个 ChangeSignedNumericTextBox 函数?
【问题讨论】:
标签: javascript jquery razor kendo-ui