这是 mvc 3 razor 视图的一部分。我在表单上有几个编辑框,想添加一点 jquery 来增强表单的健壮性。但是我遇到了一个奇怪的错误,这对我来说没有意义。
首先让我们看一下视图。
<link type="text/css" rel="stylesheet" href="/content/jquery-ui-1.8.16.custom.css"/>
<link type="text/css" rel="stylesheet" href="/content/site9.css"/>
<link rel="stylesheet" href="@Url.Content("~/jqwidgets/styles/jqx.base.css")" type="text/css" />
<link rel="stylesheet" href="@Url.Content("~/jqwidgets/styles/jqx.darkblue.css")" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.10.1.min.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.custom.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/jqwidgets/jqxcore.js")" type="text/javascript"></script>
<script src="@Url.Content("~/jqwidgets/jqxvalidator.js")" type="text/javascript"></script>
<script src="@Url.Content("~/jqwidgets/globalization/globalize.js")" type="text/javascript"></script>
<script src="@Url.Content("~/jqwidgets/jqxmaskedinput.js")" type="text/javascript"></script>
<script src="@Url.Content("~/jqwidgets/jqxinput.js")" type="text/javascript"></script>
<script src="@Url.Content("~/jqwidgets/gettheme.js")" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#date_paid').datepicker();
$("#first_name").jqxInput({ placeHolder: "First Name", width: 200, height: 25, theme: 'darkblue' });
$("#last_name").jqxInput({ placeHolder: "Last Name", width: 200, height: 25, theme: 'darkblue' });
$("#middle_initial").jqxInput({ placeHolder: "Middle Initial", width: 150, height: 25, theme: 'darkblue' });
$("#zip_code").jqxmaskedinput({ mask: '#####-####', width: 150, height: 25, theme: 'darkblue' });
});
<div class="editor-label">
<label>First Name</label>
@Html.EditorFor(Function(model) model.first_name)
@Html.ValidationMessage("first_name", "*")
<label class="small_spacing">Middle Initial</label>
@Html.EditorFor(Function(model) model.middle_initial)
@Html.ValidationMessage("middle_initial", "*")
<label class="small_spacing">Last Name</label>
@Html.EditorFor(Function(model) model.last_name)
@Html.ValidationMessage("last_name", "*")
</div>
<div class="editor-label">
<label>City</label>
@Html.EditorFor(Function(model) model.city)
@Html.ValidationMessage("city", "*")
<label class="spacing">State</label>
@Html.DropDownListFor(Function(model) model.State, New SelectList(ViewBag.states), New With {.class = "StateDrop"})
@Html.ValidationMessageFor(Function(model)model.State)
<label class="small_spacing">Zip Code</label>
@Html.EditorFor(Function(model) model.zip_code)
@Html.ValidationMessage("zip_code", "*")
</div>
所有这些看起来都很棒,但是 jqxmaskedinput 抛出了以下错误。
Uncaught TypeError: Object [object Object] has no method 'jqxmaskedinput'
jqxInput 框工作正常。如果我删除 jqxInput 框 jqxmaskedInput 工作正常。我认为这可能是两者之间的兼容性问题,但在 jqWidgets 上,我发现了一个同时使用 jqxInput 和 jqxmaskedInput 的示例,因此这不太可能是兼容性问题。作为这个领域的一个完全nooblet,我不知道这可能是什么原因......欢迎任何建议......