I have integrated a fullcalendar in my Tapestry 5.4 web page.
Whenever I create a new Event or click on an existing event, it triggers the fullcalendar's method (select
or eventClick
). These methods then call a Tapestry JS method (
zoneManager.deferredZoneUpdate("formZone", listenerURIWithValue);
) to refresh a jQuery dialog div (#formZone
) which is a Tapestry zone. The functionality works fine and the data gets updated as expected.
However, there is a visible refreshing "procedure" where after the zone-update part, the jQuery dialog opens before the refresh completes (due to asynchronous AJAX calls), resulting in an undesired visual effect.
My objective is to either define a callback function for deferredZoneUpdate
or change the code sequence like this:
...
zoneManager.deferredZoneUpdate("formZone", listenerURIWithValue);
$('#wsDialog').dialog('open');
...
Thank you in advance for any assistance!
Update:
calendar-init.js:
define(["jquery" , "t5/core/zone"], function($, zoneManager) {
return function(modifyEventLink, newEventLink, pageTurnLink, allDayText) {
$(document).ready(function() {
var calendarDiv = $('#calendar');
calendarDiv.fullCalendar({
//....init
eventClick: function(calEvent, jsEvent, view) {
// create modifyeventlink with id param
var listenerURIWithValue = appendQueryStringParameter(modifyEventLink, 'eventID', calEvent.id);
// ajax zone update
zoneManager.deferredZoneUpdate("formZone", listenerURIWithValue);
// open the worksheet dialog
$('#wsDialog').dialog('option', 'title', calEvent.title);
},
//...init
});});}}) // the code syntacs is good dont bother these :D
backend:
void onModifyEventLink() {
if(request.isXHR()) {
logger.debug("ModifyEventLink on.");
String eventID = (String) request.getParameter("eventID");
if(eventID == null) {
logger.error("wsDialog was not able to load because eventID is NULL!");
} else {
try{
wSheet = sheetService.find(Integer.valueOf(eventID));
if(wSheet != null) {
ajaxResponseRenderer
.addCallback(new JavaScriptCallback() {
@Override
public void run(JavaScriptSupport javascriptSupport) {
javascriptSupport.require("wsdialogs");
}};)
.addRender(formZone);
} else {
logger.warn("Worksheet with " + eventID + " not found.");
}
} catch (NumberFormatException e) {
logger.error("wsDialog was not able to load beacause eventID was not a number.");
logger.error("Exception: ", e.getLocalizedMessage());
}
}
} else {
logger.debug("ModifyEventLink on, request is not XHR (ajax)");
}
}
(module) wsdialogs.js:
define(["jquery" , "t5/core/zone"], function($, zoneManager) {
console.log("wsdialog-js run");
$("#wsDialog").dialog('open');
});
tml:
<t:container
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
xmlns:p="tapestry:parameter">
<t:jquery.dialog t:clientId="wsDialog" t:id="wsDialog" title="${message:wsheet-new}" style="display: none;">
<t:zone t:id="formZone" id="formZone">
<t:form t:id="worksheetForm" t:type="form" t:zone="^">
....
</t:form>
</t:zone>
</t:jquery.dialog>
</t:container>