Using prototype I load the calendar content into the page by calling:
postForm(document.forms.mainform,‘subbody’,‘calendar.html’);
/*Generic Function to post a form to the page*/
function postForm (frm,div,url) {
if(! div){div="mainbody";}
if(! $(div)){return;}
if(! frm){frm=document.forms.mainform;}
if(url){
frm.action=url;
}
var frmData = $(frm.id).serialize(true);
new Ajax.Updater({ success: div, failure: div }, frm.action,
{
method: frm.method,
onCreate: waiting(div),
parameters: frmData,
onComplete:postchck
}
);
return false;
}
calendar.html
<div id="_caltabs"></div>
<div id="appointment_calendar" class="dhx_cal_container" style='width:100%; height:100%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data">
</div>
</div>
I enter an event and it sends to my appointments.cfm and enters the correct data into the database but when I navigate away from the calendar and come back the event is gone. If I use firebug I can see the ajax call was made to the appointments.cfm file and it has the correct xml data but no events show on the calendar.
My Javascript to load the calendar
[code]//Calendar
var reucurringBlocks=new Array();
var generalBlocks=new Array();
function loadcalconfig(){
$(‘subbody’).style.width=document.documentElement.clientWidth + ‘px’;
var step = 5;
var format = scheduler.date.date_to_str("%h:%i");
var curDate = new Date();
scheduler.form_blocks[“my_editor”]={
render:function(sns){
return “
},
set_value:function(node,value,ev){
node.childNodes[1].value=value||””;
node.childNodes[4].value=ev.details||"";
node.childNodes[7].value=ev.location||"";
},
get_value:function(node,ev){
ev.details = node.childNodes[4].value;
ev.location = node.childNodes[7].value;
return node.childNodes[1].value;
},
focus:function(node){
var a=node.childNodes[1];
a.select();
a.focus();
}
}
scheduler.config.lightbox.sections=[
{ name:“description”, height:200, map_to:“text”, type:“my_editor” , focus:true},
{ name:“time”, height:72, type:“time”, map_to:“auto”}
]
scheduler.templates.event_text=function(start,end,event){
if(event.details){
return "Name: " + event.text + " " + event.details + “”;
}else{
return "Name: "+event.text + “”;
}
}
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;
scheduler.config.icons_select=[“icon_details”,“icon_delete”];
scheduler.config.scroll_hour = curDate.getHours();
scheduler.config.hour_size_px=(60/step)*21;
function block_readonly(id){
if (!id) return true;
return !this.getEvent(id).readonly;
}
scheduler.attachEvent("onBeforeDrag",block_readonly)
scheduler.attachEvent("onClick",block_readonly)
scheduler.templates.hour_scale = function(date){
html="";
for (var i=0; i<60/step; i++){
html+="<div style='height:21px;line-height:21px;'>"+format(date)+"</div>";
date = scheduler.date.add(date,step,"minute");
}
return html;
}
scheduler.attachEvent("onEventSave",function(id,data){
if (!data.text) {
alert("Please Enter a First Name");
return false;
}
if(!data.details){
alert("Please Enter a Last Name");
return false;
}
if(!data.location){
alert("Please Enter a Valid E-mail");
return false;
}else{
return checkemail(data.location);
}
return true;
})
scheduler.templates.week_date_class=function(date,today){
for (var i=0; i<reucurringBlocks.length; i++){
if(date.getDate()==reucurringBlocks[i][0] && date.getMonth()== reucurringBlocks[i][1]){
return "blockeddays";
}
}
for (var j=0; j<generalBlocks.length; j++){
if(date.getDate()==generalBlocks[j][0] && date.getMonth()== generalBlocks[j][1] && date.getFullYear()== generalBlocks[j][2]){
return "blockeddays";
}
}
return "";
}
scheduler.templates.month_date_class=function(date,today){
for (var i=0; i<reucurringBlocks.length; i++){
if(date.getDate()==reucurringBlocks[i][0] && date.getMonth()== reucurringBlocks[i][1]){
return "blockedmonthdays";
}
}
for (var j=0; j<generalBlocks.length; j++){
if(date.getDate()==generalBlocks[j][0] && date.getMonth()== generalBlocks[j][1] && date.getFullYear()== generalBlocks[j][2]){
return "blockedmonthdays";
}
}
return "";
}
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.init('appointment_calendar',null,"day");
scheduler.load("../xml/appointments.cfm?uid="+scheduler.uid());
var dp = new dataProcessor("../xml/appointments.cfm");
dp.init(scheduler);
}[/code]
My xml file geberated by coldfusion
<data>
<event id="35">
<start_date><![CDATA[2011-06-28 15:45:00]]></start_date>
<end_date><![CDATA[2011-06-28 16:20:00]]></end_date>
<text><![CDATA[Scott]]></text>
<details><![CDATA[E]]></details>
<location><![CDATA[webmaster@domain.com]]></location>
</event>
<event id="47">
<start_date><![CDATA[2011-09-02 12:20:00]]></start_date>
<end_date><![CDATA[2011-09-02 12:35:00]]></end_date>
<text><![CDATA[Scott]]></text>
<details><![CDATA[E]]></details>
<location><![CDATA[scott@domain.com]]></location>
</event>
<event id="56">
<start_date><![CDATA[2011-09-27 17:00:00]]></start_date>
<end_date><![CDATA[2011-09-27 17:35:00]]></end_date>
<text><![CDATA[Scott]]></text>
<details><![CDATA[E]]></details>
<location><![CDATA[scott@domain.org]]></location>
</event>
</data>