【问题标题】:How to implement binding throttling in Kendo UI?如何在 Kendo UI 中实现绑定限制?
【发布时间】:2015-07-17 02:34:50
【问题描述】:

您能否提供一个在 Kendo UI 中实现 throttling 的示例?

谢谢!

【问题讨论】:

    标签: kendo-ui throttling


    【解决方案1】:

    对于 Google 搜索记录,Kendo UI 现在包含一个内置的节流方法。可用于限制指定时间内函数的调用次数。

    来自 Kendo UI 文档的示例用法:

      var throttled = kendo.throttle(function() {
          console.log("hey! " + new Date());
      }, 100);
    
      // will log two times "hey":
      // (1) once for the first call
      // (2) once for the last call, roughly 100ms after the first one
      for (var i = 0; i < 10; i++) {
          throttled();
      }
    

    文档:http://docs.telerik.com/kendo-ui/api/javascript/kendo#methods-throttle

    【讨论】:

      【解决方案2】:

      您可以使用jquery-throttle-debounce 库。这是一些将它与 Kendo 数据绑定集成的 sn-ps,假设在您拥有 keyup: updateFromDataSource 之前。

      <input id="searchText" type="text" data-value-update="keyup" data-bind="value: searchTextVal, events: { keyup: searchTextKeyed  }"  />
      
      searchTextKeyed: jQuery.debounce(300, function () { this.updateFromDataSource(); }), ...
      

      【讨论】:

        猜你喜欢
        • 2016-12-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-26
        • 1970-01-01
        • 1970-01-01
        • 2018-03-17
        相关资源
        最近更新 更多