Reputation: 270
I want to change the view from month to agenda in primefaces schedule component from a js function in my xhtml. Is this possible? I tried the following code but it not works
function moveToDay(date){
var toDate = new Date(date);
alert(toDate);
$('#schedule').fullCalendar( 'changeView', 'agendaDay' );
$('#schedule').fullCalendar( 'gotoDate', toDate );
}
Here 'schedule' is the id of p:schedule component, should i change this to #calendar in function? any suggestions?
Upvotes: 1
Views: 601
Reputation: 10058
Assuming that your schedule widgetVar is scheduleWV
.
<p:schedule widgetVar="scheduleWV" >
As Pirmefaces generates the fullCalendar it adds an outer div form the original div of the fullCalendar jQuery object, taking that in consider your function would be like this.
function moveToDay(date){
//fullCalendar is the first child of the component
myFullCal = PF('scheduleWV').jq.children(":first");
var toDate = new Date(date);
myFullCal.fullCalendar( 'changeView', 'agendaDay' );
myFullCal.fullCalendar( 'gotoDate', toDate );
}
Hope this helps.
Upvotes: 1