我在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函数?
发布于 2014-06-23 11:56:50
希望这对以下方面有所帮助:
<script>
function changeme()
{
var myId = '#' + this._form.context.id;
var val = $(myId).val();
if (val > 0) {
$(myId).kendoNumericTextBox({ format: "+##.##", decimals: 2 });
}
else {
$(myId).kendoNumericTextBox({ format: "##.##", decimals: 2 });
}
}
</script>https://stackoverflow.com/questions/24362830
复制相似问题