How can I have kendo NumericTextBox keep focus dur

2019-08-19 02:29发布

I have a kendo window that contains a kendo numeric text box:

$('input').kendoNumericTextBox({
    decimals: 2,
    spinners: false
});


 $('#win').kendoWindow({
     modal: true,
     width: "969px",
     height: "646px",
     title: "NumericTextBoxTest"
 });

 $('#win').data('kendoWindow').center().open();

The jsfiddle is here http://jsfiddle.net/e6shF/40/.

In Firefox, you are unable to highlight the numeric text box value. In Chrome, you can highlight the value but can't type over the value while it is highlighted.

It appears to be a focus issue due to improper z-indexing. I'm using kendo version 2012.3.1114 (latest GPL release). This issue is no longer present in kendo version 2012.3.1315 but that version doesn't appear to be available under GPL. How can I resolve this issue using kendo 2012.3.1114?

1条回答
家丑人穷心不美
2楼-- · 2019-08-19 03:08

Adding a .focus() event listener to the input, wrapped in a setTimeout with an input.select() seems to force it to behave normally.

$('input').kendoNumericTextBox({
    decimals: 2,
    spinners: false
}).focus(function() {
   var input = $(this);
    setTimeout(function() {
        input.select();
    });
});

Fiddle: http://jsfiddle.net/HwrzV/1/

Works for me now in Firefox and Chrome. Tried to test IE8 but JSFiddle doesn't load. :x

查看更多
登录 后发表回答