插入对jquery的引用时页面继续加载

时间:2015-03-03 00:48:22

标签: javascript jquery asp.net-mvc-3 validation

我真的觉得这是一个愚蠢的问题,但我无法弄清楚: 这是我的cshtml文件,它的渲染效果很好:

@model CrashTestScheduler.Entity.Model.Channel
@{
    string editFormat = string.Format("<button type='button' class='editForm' data-val-id=\"{0}\"><span class='ico-edit'></span></button>", ".Id");
    const string DeleteFormat = "<button type='button' class='awe-btn' onclick=\"awe.open('deleteChannel', { params:{ id: .Id } })\"><span class='ico-del'></span></button>";
    const string EditFormat = "<button type='button' class='awe-btn' onclick=\"awe.open('editChannel', { params:{ id: .Id } })\"><span class='ico-edit'></span></button>";

}

<script>
    $(function() {
        awe.popup = bootstrapPopup;
    });

    var getChannelGroupNameHandler = function (item) {
        if (item.ChannelGroupName == null || item.ChannelGroupName=='') {
            item.ChannelGroupName = $("#ChannelGroupId option:selected").text();
        }
    }

</script>

<div id="wrap">

    <div id="page-heading">
        <ol class="breadcrumb">
            <li><a href="/Home/index">Home</a></li>
            <li class="active">Channels</li>
            <li style="display:none;"></li>
        </ol>
    </div>

    <div class="container">

        <div class="col-md-12" id="gridRowChannels">

            <div class="col-md-12">
                <div class="panel panel-midnightblue-header">
                    <div class="panel-heading">
                        <h3>Channel List</h3>
                        <div class="options">

                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row-sub">
                            <button type="button" id="btnAddProject" class="btn btn-primary" onclick="awe.open('createChannel')">
                                Add Channel
                            </button>
                        </div>
                        <div class="row-sub">
                            @Html.Awe().InitPopupForm().Name("createChannel").Url(Url.Action("Create", "ChannelsGrid")).Success("itemCreated('ChannelsGrid',getChannelGroupNameHandler)").OkText("Add").Title("Add Channel")
                        </div>
                        <div class="row-sub">
                           @Html.Awe().InitPopupForm().Name("deleteChannel").Url(Url.Action("Delete", "ChannelsGrid")).Success("itemDeleted('ChannelsGrid')").Parameter("gridId", "ChannelsGrid").Height(200).Modal(true).Title("Delete Channel").OkText("Delete")
                        </div>
                        <div class="row-sub">
                            @Html.Awe().InitPopupForm().Name("editChannel").Group("Channel").Url(Url.Action("Edit", "ChannelsGrid")).Success("itemUpdated('ChannelsGrid',getChannelGroupNameHandler)").OkText("Save").Title("Edit Channel")
                        </div>


    <div class="row-sub">


        @(Html.Awe().Grid("ChannelsGrid")
              .Url(Url.Action("GetItems", "ChannelsGrid"))
              .Columns(
                  new Column {Name = "Name", Header = "Channel Name", Sort = Sort.Asc},
                  new Column {Name = "ChannelGroup.Name", Header = "Channel Group", ClientFormat = ".ChannelGroupName"},
                  new Column {ClientFormat = DeleteFormat, Width = 50},
                  new Column {ClientFormat = EditFormat, Width = 50}

              )

              .Sortable(true)
              .SingleColumnSort(true)
              .LoadOnParentChange(false)
              .PageSize(20)
              .Groupable(false))

    </div>


                    </div>
                </div>
            </div>
        </div>



        <div class="col-md-12" id="pnlEditproject" style="display: none;">
        </div>
    </div>
</div>

但是我想稍后使用jquery来使用jquery验证。所以在这里我将它们插入到文件中。

<script src="~/Scripts/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.validate.min.js"></script>

现在无法呈现文件,页面继续加载和加载。有线索吗?

1 个答案:

答案 0 :(得分:0)

看起来您已经可以访问此页面中的jQuery库,因为您正在使用...

$(function() {
        awe.popup = bootstrapPopup;
    });

请删除新的引用并尝试查看页面源以查找已有的库列表。