这是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工作正常。我认为这可能是2之间的兼容性问题但是在jqWidgets上我找到了一个同时使用jqxInput和jqxmaskedInput的示例,因此这是兼容性问题的可能性很小。作为这个领域的一个完全nooblet我迷失了可能是什么原因..任何建议都欢迎..
答案 0 :(得分:1)
Javascript区分大小写。拨打.jqxmaskedinput
的电话应为.jqxMaskedInput
。