2016-08-23 55 views
0

我在更新val时不能更新kendoNumericTextBox,直到我将光标放入文本框时才显示。设置值时KendoNumericTextbox不更新

$(document).ready(function() { 
 
    
 
$('#txtCorpEl').kendoNumericTextBox({}).data("kendoNumericTextBox"); 
 
    
 
$('#txtCorpEl').value(5); 
 
    
 
$('#txtCorpEl').focus(); 
 
    
 
//var numerictextbox = $("#txtCorpEl").data("kendoNumericTextBox"); 
 
//numerictextbox.focus(); 
 
    
 
}); 
 
    
 
    
 
function onChange() { 
 
    console.log("event: change"); 
 
};
<link href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.common.min.css" rel="stylesheet"/> 
 
<link href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.default.min.css" rel="stylesheet"/> 
 
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>   
 
<script src="http://cdn.kendostatic.com/2011.3.1129/js/kendo.all.min.js"></script> 
 
<input id="txtCorpEl" />

+0

尝试使用自己的价值函数,而不是jQuery的VAL http://demos.telerik.com/kendo-ui/numerictextbox/api – Nikki9696

+0

伟大的建议,但......“遗漏的类型错误:$(...)。值不是一个函数“ –

+0

你需要在他们的元素上使用它们。一会儿。 – Nikki9696

回答

1

当我测试了这是工作的罚款。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> 
    <link href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.common.min.css" rel="stylesheet"/> 
<link href="http://cdn.kendostatic.com/2011.3.1129/styles/kendo.default.min.css" rel="stylesheet"/> 
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>   
<script src="http://cdn.kendostatic.com/2011.3.1129/js/kendo.all.min.js"></script> 
</head> 
<body> 
<input id="txtCorpEl" /> 
<script> 
    $(document).ready(function() { 
     $("#txtCorpEl").kendoNumericTextBox(); 
    var numerictextbox = $("#txtCorpEl").data("kendoNumericTextBox"); 
numerictextbox.value(5); 
}); 
</script> 
</body> 
</html>