admin管理员组文章数量:1430683
I want to implement Jquery datepicker into JSF page like this example. So far I managed to call the calendar into JSF input field using this code:
//For calendar
function calendar(){
// Datepicker
$('#datepicker').datepicker({
inline: true,
showWeek: true,
firstDay: 1
});
}
I use this input field to call the code:
<h:panelGroup>
<div id="datepicker"></div>
<h:inputText onfocus="calendar()" value="#{DatabaseController.formMap['userid']}" >
</h:inputText>
</h:panelGroup>
When I click on the input field the calendar is displayed.
I want to implement the example into the JQuery web site but in my case when I click outside the input field the calendar does not hide as should be. How I can fix this?
Best Wishes Peter
I want to implement Jquery datepicker into JSF page like this example. So far I managed to call the calendar into JSF input field using this code:
//For calendar
function calendar(){
// Datepicker
$('#datepicker').datepicker({
inline: true,
showWeek: true,
firstDay: 1
});
}
I use this input field to call the code:
<h:panelGroup>
<div id="datepicker"></div>
<h:inputText onfocus="calendar()" value="#{DatabaseController.formMap['userid']}" >
</h:inputText>
</h:panelGroup>
When I click on the input field the calendar is displayed.
I want to implement the example into the JQuery web site but in my case when I click outside the input field the calendar does not hide as should be. How I can fix this?
Best Wishes Peter
Share Improve this question edited May 16, 2012 at 15:34 Peter Penzov asked May 16, 2012 at 15:24 Peter PenzovPeter Penzov 1,620156 gold badges502 silver badges912 bronze badges 2-
2
With regard to "don't reinvent the wheel", PrimeFaces (which also uses jQuery UI under the covers) has a
<p:calendar>
which works just as you describes, without additional boilerplate code: primefaces/showcase/ui/calendarBasic.jsf – BalusC Commented May 16, 2012 at 15:26 -
I agree, but I need to use my custom JQuery ponents. Into the example that I fount the calender is called into the html page as
div
. How I can can this into the JSF page? – Peter Penzov Commented May 16, 2012 at 15:36
3 Answers
Reset to default 2You can use the classname instead of the id. Put this JS and the end before the </h:body>
<script type="text/javascript">
//For calendar
$(".datepicker").datepicker({
inline: true,
showWeek: true,
firstDay: 1
});
</script>
And this is the input field with the calendar.
<h:inputText styleClass="datepicker" value="#{DatabaseController.formMap['userid']}" > </h:inputText>
you need to create a event function to run the $( "#datepicker" ).datepicker("hide");
line when the element loses focus. You can do this with something like:
$("#dateInputElementIdGoesHere").blur(function() {
$( "#datepicker" ).datepicker("hide");
});
first add this line in JSP page:
<link rel="stylesheet" href="http://code.jquery./ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script>
$(function() {
$( "#form1\\:enddate" ).datepicker();
});
</script>
<h:form id="form1">
<div>
<h:outputLabel for="etmonth" value="End Month" style="font-size:20px"></h:outputLabel>
<h:inputText id="enddate" value="" style="width:208px;height:20px;margin-left:28px;"></h:inputText>
</div>
</h:form>
And note this:
description: form1=formid and enddate =inputtext_id
praveen sharma
本文标签: javascriptCall Jquery datepicker in JSF pageStack Overflow
版权声明:本文标题:javascript - Call Jquery datepicker in JSF page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745529633a2661998.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论