【问题标题】:Kendo UI window - prevent loading previous contentKendo UI 窗口 - 防止加载以前的内容
【发布时间】:2014-05-03 10:29:10
【问题描述】:

我在我的 MVC 项目中使用 Kendo Window。

这就是我从视图中启动对象的方式

@(Html.Kendo().Window()
    .Name("window")
    .Content("loading page..")
    .Iframe(true)
    .Draggable()
    .Visible(false)
    .Height(200)
    .Width(400)
    .Modal(true)
)



这就是我使用 _url 是动态的 javaScript 调用窗口的方式

$('#window')
   .data("kendoWindow")
   .title("Add new category")
   .refresh({
       url: _url
   })
   .center()
   .open();


我的问题是,每当我第二次打开窗口时,它仍然会显示以前的内容,直到完成加载当前内容。

我尝试使用以下方法首先隐藏内容:

$('#window')
     .kendoWindow({
         visible: false
     })
     .data("kendoWindow")
     .title("Add new category")
     .refresh({
         url: _url
     })
     .center()
     .open();

但是当我试图关闭它时,它似乎被破坏了。

【问题讨论】:

    标签: asp.net-mvc model-view-controller kendo-ui kendo-window


    【解决方案1】:

    使用这个:

    $('#window')
       .data("kendoWindow")
       .title("Add new category")
       .content("") //this little thing does magic 
       .refresh({
          url: _url
       })
       .center()
       .open();
    

    不过,我建议您重新安排通话时间:

     $('#window')
       .data("kendoWindow")
       .title("Add new category")
       //.content("") //this little thing does magic 
       .content("<img src='ajax-loader.gif' alt='Loading...'/>")
       .center()
       .open();
       .refresh({
          url: _url
       })
    

    使用第二个配置并提供有效的加载图像,用户将看到您的窗口并被告知内容正在加载。这非常有用(更不用说用户友好了),因为当您使用 refresh 函数时,Kendo 窗口会发出 AJAX 请求。

    或者,您可以在窗口close 事件上添加一个事件,并在处理程序中设置content("")

    【讨论】:

      【解决方案2】:

      您可能还想添加

      .Events(e =>
      {
          e.Refresh("onRefresh");
      })
      
      <script>
          function onRefresh() {
              this.center();
          }
      <script>
      

      在内容加载后保持窗口居中,因为它是异步加载的。

      (如果您的内容高度可变)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多