Declined
Last Updated: 20 Nov 2014 18:31 by ADMIN
Kevin
Created on: 07 May 2012 18:10
Category: Kendo UI for jQuery
Type: Feature Request
2
NumericTextBox.enable(false) Bug
Hey,
I am not sure, if it is a bug, or if I am just wrong, but I tried this:

    $(".DatePicker").kendoDatePicker();
    $(".DatePicker").data("kendoDatePicker").enable(false);
    $(".NumericTextBox").kendoNumericTextBox();
    $(".NumericTextBox").data("kendoNumericTextBox").enable(false);

This works fine for all DatePickers, but on NumericTextBoxes it thows an exception ("object is null or undefined"). Using ids to enable/disable NumericTextBoxes works though.
3 comments
Kevin
Posted on: 08 May 2012 20:09
Hi Brandon,

because it works fine with the DatePicker I thought it would be a bug, not working with NumericTextBox. Thanks for your detailed note and I think I will go with " I'd suggest refining the jQuery selector to be more specific so as to avoid selecting the secondary text box."

Thanks.

Kevin Lippert
ADMIN
Brandon
Posted on: 08 May 2012 17:07
NumericTextBox controls create two inputs for styling purposes and copy existing styles (inline and classes) to a secondary control, which is what causes this behavior. An ID or more-specific class should be used instead.
ADMIN
Brandon
Posted on: 08 May 2012 17:06
Hi Kevin,

When using the NumericTextBox, I'd recommend using an Id or name instead of class to select your NumericTextBoxes. 

So this,

$('#numBox').kendoNumericTextBox();
$('#numBox').data("kendoNumericTextBox").enable(false);

Will work just fine. Here's a fiddle illustrating this: http://jsfiddle.net/bsatrom/bbN4Z/

Here's a bit more background: the NumericTextBox is actually rendered in markup as two controls, one that contains the formatted value, and other containing the value posted to the server. Any styles you define on the original element are copied to the secondary display element, which includes inline styles and classes.

Thus, when you create the NumericTextBox with class="NumericTextBox," it results in two controls with that class but only one is bound to jQuery.data(), which is why enable() isn't working for you. Ids, on the other hand, are not copied to the secondary control and as such, operate as desired.

If you really need to use class names because you are working with groups of NumericTextBoxes as opposed to a single box, I'd suggest refining the jQuery selector to be more specific so as to avoid selecting the secondary text box.

This behavior is by design and is not considered a bug, though I did make a note to add a note about the use of IDs instead of classes in the docs.

Thanks, I hope that helps!

Brandon Satrom