我創建使用 1-引導日期選擇器的JS/CSS文件,彈出日期選擇器(localted在web目錄,幷包含在HTML文件) 2 - GWT創建文本框控件日期選擇器,其中日期應填寫鏈接JavaScript和GWT部件
我面臨的問題是,js無法識別我在GWT中創建的文本框,而如果我直接在html文件中插入文本框,datepicker正在工作文件(js正在工作)
這是我使用的HTML文件
<html>
<head>
<title>Application</title>
<link rel="stylesheet" href="resources/css/datepicker.css" rel="stylesheet"/>
</head>
<body>
<script type="text/javascript" language="javascript" src="com.myApp.Users/com.myApp.Users.nocache.js"></script>
<h1>Users Application</h1>
</body>
<div id="3b2">
<!-- when adding the below element it is working fine -->
<!--<input type="text" placeholder="flight date" id="airlineCal" class="input-block-level">-->
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="resources/js/bootstrap-datepicker.js"></script>
<script src="resources/js/triphop.js"></script>
<script>
$(document).ready(function() {
$("#airlineCal").datepicker({
format: "dd/mm/yyyy"
});
});
</script>
</html>
,這是我如何創建一個構件
final TextBox flightdateTextBox = new TextBox();
flightdateTextBox.getElement().setPropertyString("id", "airlineCal");
RootPanel.get("3b2").add(flightdateTextBox);
作爲一種解決方法,我在html中插入輸入文本,並開始使用DOM庫(((InputElement)(Element)DOM.getElementById(「airlineCal」))。getValue();) –