从cshtml页面调用javascript方法

时间:2015-04-06 22:36:25

标签: jquery model-view-controller

我正在尝试调用javascript页面但是它出错了

" JavaScript运行时错误:' $ ObligationfeeType'未定义"。

这是我的javascript代码

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>

任何人都可以帮我解决这个问题。

0 个答案:

没有答案