Jquery 从cshtml页面调用javascript方法
我试图调用javascript页面,但它给出了一个错误 “JavaScript运行时错误:“$ObligationfeeType”未定义” 下面是我的javascript代码Jquery 从cshtml页面调用javascript方法,jquery,model-view-controller,Jquery,Model View Controller,我试图调用javascript页面,但它给出了一个错误 “JavaScript运行时错误:“$ObligationfeeType”未定义” 下面是我的javascript代码 var $ObligationfeeType = function() { var privateMethods = { getNameDropdownValueObject: function() { return $("#ObligationsGuarantorName
var $ObligationfeeType = function() {
var privateMethods = {
getNameDropdownValueObject: function() {
return $("#ObligationsGuarantorName").data("kendoDropDownList");
}
};
var events = {
feeTypeOnselect: function(e) {
if (e.item.index() > 0) {
privateMethods.getNameDropdownValueObject().wrapper.find(".k-dropdown-wrap").removeClass("k-invalid");
}
},
onDollarAmountChange: function(e) {},
onPercenatgeAmountChange: function(e) {},
onBasisPointChange: function(e) {}
};
return {
"feeTypeOnselect": events.feeTypeOnselect,
"onDollarAmountChange": events.onDollarAmountChange,
"onPercenatgeAmountChange": events.onPercenatgeAmountChange,
"onBasisPointChange": events.onBasisPointChange
};
}();
这是我的cshtml页面
@{
ViewData.TemplateInfo.HtmlFieldPrefix = "";
Layout = Request.IsAjaxRequest() ? null : "~/Views/Shared/_Layout.cshtml";
}
@using EntryPointCRR.Models
@model ObligationsFeesInfo
<script src="../../../Scripts/PageJS/ObligationFeeType.js" type="text/javascript"></script>
<div>
<div class="errorNotifications" style="display: none;">
<span class="fa fa-warning"></span>
<div id="dvErrorMessages">
</div>
</div>
<div>
Fee Type
<div class="requiredContainer">
<span class="required">*</span></div>
</div>
<div>
<div id="dvObligationsFeesTypeList">
@(Html.Kendo().DropDownListFor(model => model.Type)
.OptionLabel("Select")
.DataValueField("Value")
.DataTextField("Text")
.DataSource(datasource => datasource.Read("GetFeeTypes", "ObligationsFees"))
.Events(e =>
{
e.Select("$ObligationfeeType.feeTypeOnselect");
})
)
<div id="dvTypeOther">
@(Html.DisplayTextFor(model => model.FeeTypeOther))@(Html.TextBoxFor(model => model.FeeTypeOther))
</div>
</div>
<div>
@(Html.DisplayTextFor(model => model.AmountType))
<div>
@(Html.RadioButton("FeeType", false, new {id = "rbDollor"}))
@Html.DisplayNameFor(model => model.FeeAmountDollar)
@(Html.Kendo().NumericTextBoxFor(model => model.FeeAmountDollar).Events(evt => evt.Change("$ObligationfeeType.onDollarAmountChange")).Min(0).Step(1).Format("#.00").Spinners(false).HtmlAttributes(new { @class = "fieldSml", disabled = true }))
</div>
<div>
@(Html.RadioButton("FeeType", false, new { id = "rbPercentage" }))
@Html.DisplayNameFor(model => model.FeeAmountPercentage)
@(Html.Kendo().NumericTextBoxFor(model => model.FeeAmountPercentage).Events(evt => evt.Change("$ObligationfeeType.onPercenatgeAmountChange")).Min(0).Max(100).Step(1).Format("#.00").Spinners(false).HtmlAttributes(new { @class = "fieldSml", disabled = true }))
</div>
<div>
@(Html.RadioButton("FeeType", false, new { id = "rbBasisPoint" }))
@Html.DisplayNameFor(model => model.FeeAmountBasisPoint)
@(Html.Kendo().NumericTextBoxFor(model => model.FeeAmountBasisPoint).Events(evt => evt.Change("$ObligationfeeType.onBasisPointChange")).Min(0).Step(1).Format("#.00").Spinners(false).HtmlAttributes(new { @class = "fieldSml", disabled = true }))
</div>
</div>
</div>
</div>
@{
ViewData.TemplateInfo.HtmlFieldPrefix=“”;
Layout=Request.IsAjaxRequest()?空:“~/Views/Shared/_Layout.cshtml”;
}
@使用EntryPointCRR.Models
@模型倾斜费信息
费用类型
*
@(Html.Kendo().DropDownListFor(model=>model.Type)
.选项标签(“选择”)
.DataValueField(“值”)
.DataTextField(“文本”)
.DataSource(DataSource=>DataSource.Read(“GetFeeTypes”,“ObligationsFees”))
.事件(e=>
{
e、 选择($ObligationfeeType.feeTypeOnselect);
})
)
@(Html.DisplayTextFor(model=>model.FeeTypeOther))@(Html.TextBoxFor(model=>model.FeeTypeOther))
@(Html.DisplayTextFor(model=>model.AmountType))
@(Html.RadioButton(“FeeType”,false,new{id=“rbDollor”}))
@DisplayNameFor(model=>model.FeeAmountDollar)
@(Html.Kendo().NumericTextBoxFor(model=>model.FeeAmountDollar).Events(evt=>evt.Change($ObligationfeeType.onDollarAmountChange)).Min(0).Step(1).Format(“#.00”).Spinners(false).HtmlAttributes(new{@class=“fieldSml”,disabled=true}))
@(Html.RadioButton(“FeeType”,false,new{id=“rbPercentage”}))
@DisplayNameFor(model=>model.FeeAmountPercentage)
@(Html.Kendo().NumericTextBoxFor(model=>model.FeeAmountPercentage).Events(evt=>evt.Change($ObligationfeeType.onPercenatgeAmountChange)).Min(0).Max(100).Step(1).Format(“#.00”).Spinners(false).HtmlAttributes(new{@class=“fieldSml”,disabled=true})
@(Html.RadioButton(“FeeType”,false,new{id=“rbBasisPoint”}))
@DisplayNameFor(model=>model.FeeAmountBasisPoint)
@(Html.Kendo().NumericTextBoxFor(model=>model.FeeAmountBasisPoint).Events(evt=>evt.Change($ObligationfeeType.onBasisPointChange)).Min(0).Step(1).Format(“#.00”).Spinners(false).HtmlAttributes(new{@class=“fieldSml”,disabled=true})
有人能帮我解决这个问题吗。您确认文件正在浏览器中加载吗?哦。谢谢@charlietfl。我传递了一个worng jscript文件路径。谢谢