2016-08-23 54 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>