【问题标题】:need to know, using jquery, when a razor view is loaded需要知道,使用 jquery,何时加载剃刀视图
【发布时间】:2016-01-09 01:12:30
【问题描述】:

我有一个包含引导面板的剃刀局部视图。它使用 jquery 在模式窗口中加载。根据设计,该视图应该具有始终可见的标题和页脚部分,并且正文部分应该是可滚动的。我可以通过将 div class=panel-body 的高度设置为例如 400px 来完成此操作,但我想在模态打开之前在 jquery 中将其设置为根据模态的高度确定的值窗口,我知道如何得到它。我的问题是如何将它应用到正文部分,动态使用 jquery?或者,换句话说:如何检测何时加载此特定视图?

RoomingList.cshtml

<div id="panelRoomingList" class="panel panel-primary nopadding">
    <div class="panel-heading">
    </div>
    <div id="panelBody" class="panel-body" style="height:400px; overflow-y:scroll">
       </div>
    <div class="panel-footer text-center" style="margin-top:30px;">
    </div>
</div>

重要提示:伪脚本仅用于 ilustration。 为简单起见,已将其缩短,请忽略任何代码错误(如果有)。原版按预期工作。

function ShowRoomingList() {
  $.ajax({
    url: ShowRoomingListUrl,
    type: "GET",
    cache: false,
    success: function () {
      $("#modal_RoomingList").modal("show");
      $("#modal_RoomingList").html(data);
    }
  },
  error: function (xhr, status, exception) { 
    DisplayAjaxError(xhr, status, exception); }
  });
}

【问题讨论】:

  • 在ajax调用的success函数中可以知道这个负载是被加载的吧?

标签: jquery asp.net-mvc-4 razor


【解决方案1】:

使用ajax success 函数(您正在显示模型对话框的位置)将动态属性(在您的情况下为高度)设置为模式对话框。

【讨论】:

    猜你喜欢
    • 2018-04-24
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-05
    • 1970-01-01
    相关资源
    最近更新 更多