kendo.widgetInstance throws exception TypeError: t is undefined

喜欢而已 提交于 2019-12-02 18:50:08

问题


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);
    }
});

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.com/getting-started/widgets#getting-reference-to-an-unknown-kendo-ui-widget

Using the 2013.2.918 version.

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.


回答1:


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);

See it work: http://jsfiddle.net/lhoeppner/798Rd/



来源:https://stackoverflow.com/questions/20061278/kendo-widgetinstance-throws-exception-typeerror-t-is-undefined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!