Applying k-state-disabled class to text inputs - Kendo UI

戏子无情 提交于 2019-12-05 17:43:00
OnaBai

I think that easiest and more portable way of doing it is by adding / removing k-state-disabled when you set the disabled property value.

Example for enabling you textbox:

$("#textboxtest").prop("disabled", false).removeClass("k-state-disabled");

for disabling it:

$("#textboxtest").prop("disabled", true).addClass("k-state-disabled");

Your JSFiddle modified with two buttons for enabling / disabling it http://jsfiddle.net/KrW6f/5/

Edit: Another possibility is defining the field as an autocomplete without a dataSource. Then you actually not need to define any CSS class. Your input field definition would be:

<input id="textboxtest" data-role="autocomplete" type="text" disabled="disabled" value="test" style="width: 300px" />

And you can see it in this other JSFiddle: http://jsfiddle.net/OnaBai/94HDF/2/

If you need to do this in the on ready then this might help:

if ($('#textboxtest').attr('disabled')=='disabled')
    $('#textboxtest').addClass('k-state-disabled');
else
    $('#textboxtest').removeClass('k-state-disabled');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!