kendo.widgetInstance引发异常TypeError:t未定义 [英] kendo.widgetInstance throws exception TypeError: t is undefined

查看:76
本文介绍了kendo.widgetInstance引发异常TypeError:t未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用kendo.widgetInstance()获取kendo控件的实例:

I'm trying to use kendo.widgetInstance() to get an instance of a kendo control:

$.each($('#AttributeForm').find(':input'), function(index, element) {
    if ($(element).closest('.k-widget').length > 0) {
        var widgetObject = kendo.widgetInstance($(element), kendo.ui);

        if (typeof widgetObject != 'undefined') widgetObject.enable(false);
    }
});

但是,kendo.widgetInstance()函数总是抛出错误,TypeError:t未定义.

However, the kendo.widgetInstance() function is always throwing an error, TypeError: t is undefined.

此代码改编自以下页面:

This code is adapted from the following page:

http://docs.kendoui.c​​om/getting-started/widgets#getting-reference-to-an-unknown-kendo-ui-widget

使用2013.2.918版本.

Using the 2013.2.918 version.

这是获取剑道小部件实例的正确方法吗?我要做的就是禁用表单中的所有kendo小部件,有几种不同的类型,但我不知道它们是多少或什么类型.

Is this the correct way to get an instance of a kendo widget? All I want to do is disable all the kendo widgets inside the form and there are several different types but I don't know how many or what type they are.

已更新,以显示禁用剑道控件的正确方法以及对我有用的最终代码.

Updated to show the correct way to disable a kendo control and the final code that worked for me.

推荐答案

文档至少在此版本的Kendo UI上不正确. kendo.widgetInstance需要第二个参数(文档当前指出该参数是选修的).根据使用的是Web还是Mobile,必要的参数是kendo.uikendo.mobile.ui.因此,您需要将通话更改为:

The documentation is incorrect, at least for this version of Kendo UI. kendo.widgetInstance requires a second parameter (the documentation currently states this parameter is optional). Depending on whether you use Web or Mobile, the necessary parameter is kendo.ui or kendo.mobile.ui. So you need to change your call to:

var widgetObject = kendo.widgetInstance(widgetElement, kendo.ui);

查看其工作原理: http://jsfiddle.net/lhoeppner/798Rd/

这篇关于kendo.widgetInstance引发异常TypeError:t未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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