在MVC中控制Kendo脚本位置渲染 [英] Control Kendo Script Position Rendering in MVC

查看:19
本文介绍了在MVC中控制Kendo脚本位置渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Kendo ASP.NET MVC 包装器.我注意到包装器正在呈现脚本以在控件标记后立即初始化控件.有没有办法配置让脚本呈现在底部?之前,使用 Telerik ASP.NET MVC 控件,您可以让脚本管理器在底部呈现所有初始化.这可能吗?

I'm using the Kendo ASP.NET MVC wrappers. I noticed the wrappers are rendering the scripts to initialize the controls immediately after the control markup. Is there a way to configure to have the scripts render at the bottom? Before, with the Telerik ASP.NET MVC controls, you could have the script manager render all the initializations at the bottom. Is that possible?

推荐答案

在 2013 Q1 版本中,他们添加了对延迟脚本的支持.你可以这样使用它:

In the 2013 Q1 release, they added support for deferred scripts. You can use it like so:

@(Html.Kendo().AutoCompleteFor(m => m)
    .Filter(FilterType.Contains)
    .MinLength(2)
    .DataSource(config =>
        {
            config.Read(action, controller, routeValues);
            config.ServerFiltering(true);
        }).Deferred())

注意链末尾的 Deferred() 方法.然后,在您的布局中,在标记的任意位置添加以下内容:

Note the Deferred() method in the end of the chain. Then, in your layout add the following anywhere in your markup:

  <!-- ... -->
  @Html.Kendo().DeferredScripts()
  </body>
</html>

http://www.kendoui.c​​om/forums/mvc/general-discussions/kendo-initialization-scripts-in-body-interfere-with-other-libraries.aspx 了解更多信息.

这篇关于在MVC中控制Kendo脚本位置渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆