messy cross browser problem
I am maintainning a schedueling system built with jquery and php that I did not write. As shown in the image there are links that say Full or Open. If you click on the Full link it shows the details of the appintment. If you click on the Open link it should open a blank form so you can enter the appointment information.
In IE clicking on Open always opens a blank form, which is good. In Firefox clicking on Open fills the form with the previous clicked on Full forms information, instead of opening a blank form, which is bad. FireFox only opens a blank form if the user's first click is on an Open link.
Here is the messy code. I appologize for the amount of code and hope it makes sense. I bolded the section for clicking the Open link. Since only FireFox populates an Open slot with the previous viewed Full slot, I figure it must be the jquery running on the client that is causing the problem.
- // Dialogue call change edit appointment box
//alert($("#date").val());
$("#formWindow").dialog(
{
//Edit appointment box properties
modal:true,
autoOpen:false,
width:500,
draggable:false,
resizable: false,
close: function(event,ui)
{
$("#logLink").css("display","none");
$("#alertLink").css("display","none");
$("#time").attr("value",$(this).attr("href"));
$("#formWindow").dialog('destroy');
$("#newappointmenttable label").css("display","none");
$('#log').html('');
$('#alertCounselor').html('');
document.newappointmentform.reset();
$("#date").val(selectedDate);
}
});
$("#formWindow").dialog("option","buttons",buttons);
$("#formWindow").dialog("open");
}
function showSched(data)
{
$("#sched").html(data);
var tmpDate = cDate.getMonth()+1;
if(tmpDate < 10)
{
tmpDate = "0"+tmpDate;
}
var tmp = cDate.getDate();
var dateStr = cDate.getFullYear()+"-"+tmpDate+"-"+tmp;
- if(dateStr == selectedDate)
{
$(".status").html("Full/Check-in");
}
if($("#sched").css('display')=="none")
{
$("#sched").show('slide',{direction:'left'},350);
}
//crappy active wait to wait for the database to update
function wait(mill)
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < mill);
}
//this is where we build the form popup
//if they click the open link
$(".open").click(function(event){
//the time of the appointment is stored in the href of the open link
$("#time").attr("value",$(this).attr("href"));
$("#counselor_name").attr("value",$(this).attr("title"));
$("#formWindow").attr("title","Set New Appointment");
//cancel the normal click behavior (following the link)
event.preventDefault();
//show the form
$("#phone_appointment").removeAttr('checked');
$("#have_file").removeAttr('checked');
showForm();
});
//if they wish to edit a previously sched. appointment.
//by clicking on a full appointment
$(".full").click(function(event)
{
clicked = $(this);
//stop the default click behavior
event.preventDefault();
$("#time").attr("value",$(this).attr("href"));
//alert($("#time").attr("value"));
$("#counselor_name").attr("value",$(this).attr("title"));
$("#date").attr("value",selectedDate);
$("#formWindow").attr("title","Edit Appointment");
//POST TO LOOKUP.PHP for information
$.post('lookup.php',{date:selectedDate,time:$(this).attr("href")},function(data){
//repopulate the submission form
//alert(data);
$('#logLink').css('display','none');
$('#alertLink').css('display','none');
$("#student_first_name").attr("value",data.student_first_name);
$("#student_last_name").attr("value",data.student_last_name);
$("#time").attr("value",data.appointment_time)
$("#student_number").attr("value",data.student_number);
$("#creator_initials").attr("value",data.creator_initials);
$("#aid_year").attr("value",data.aid_year);
$("#callers_name").attr("value",data.callers_name);
$("#callers_relationship").attr("value",data.callers_relationship);
$("#timezone").attr("value",data.timezone);
$("#phone_number").attr("value",data.phone_number);
$("#comments").attr("value",data.comments);
$("#appointment_id").attr("value",data.appointment_id);
if(data.phone_appointment=='t')
{
$("#phone_appointment").attr("checked","true");
} else
{
$("#phone_appointment").removeAttr('checked');
}
if(data.have_file=='t')
{
$("#have_file").attr("checked","true");
} else
{
$("#have_file").removeAttr('checked');
}
$.post('log.php',{student_number:data.student_number},function(data)
{
if(data)
{
$('#log').html(data);
$('#logLink').css('display','table');
}
},'html');
$.post('alert.php',{student_number:data.student_number},function(data)
{
if(data)
{
$('#alertCounselor').html(data);
$('#alertLink').css('display','table');
}
},'html');
},"json");
showForm('full');
});
$('#logLink').click(function(event){
$('#log').dialog({
modal:true,
draggable:false,
width:250,
resizable:false,
buttons: {
"OK":function()
{
$('#log').dialog('destroy');
}
}
});
});
$('#alertLink').click(function(event){
$('#alertCounselor').dialog({
modal:true,
draggable:false,
width:350,
resizable:false,
buttons: {
"OK":function()
{
$('#alertCounselor').dialog('destroy');
}
}
});
});
$(".closebutton").click(function(event){
//stop the click behavior
event.preventDefault();
//set all the values on the form
$("#time").attr("value",$(this).attr("href"));
$("#counselor_name").attr("value",$(this).attr("title"));
closeFull=$(this).hasClass('closeFull');
$("#date").attr("value",selectedDate);
$("#close").dialog({
modal:true,
draggable:false,
width:370,
resizable:false,
buttons: {
"Cancel":function()
{
$("#close").dialog('destroy');
},
"OK":function()
{
$("#close").dialog('destroy');
//put excuse dialog here
if(closeFull)
{
$('#cancelReason').dialog({
modal:true,
draggable:false,
width:370,
resizable:false,
buttons:{
"Cancel":function()
{
document.cancelForm.reset();
$("#cancelReason").dialog('destroy');
},
"OK":function()
{
var rea = $("#reason").attr("value");
$("#cancel_reason").attr("value",rea);
//alert($("#cancel_reason").attr("value"));
$.post("close.php?action=closed",$("#newappointmentform").serialize(),function(data)
{
//debug
//alert(data);
},"text");
$.ajax({
type:'POST',
cache:false,
url:'query.php',
data:{date:selectedDate,id:appointment_id},
success:showSched
});
$("#cancelReason").dialog('destroy');
document.cancelForm.reset();
}
}
});
}
else
{
$.post("close.php?action=closed",$("#newappointmentform").serialize(),function(data)
{
//debug
//alert(data);
},"text");
document.newappointmentform.reset();
$("#formWindow").dialog('destroy');
}
}
}
});
});
$(".openbutton").click(function(event){
//stop the click behavior
event.preventDefault();
//set all the values on the form
$("#time").attr("value",$(this).attr("href"));
$("#appointment_id").attr("value",$(this).attr("name"));
$("#counselor_name").attr("value",$(this).attr("title"));
$("#date").attr("value",selectedDate);
$("#open").dialog({
modal:true,
draggable:false,
width:370,
resizable:false,
buttons: {
"Cancel":function()
{
$("#open").dialog('destroy');
},
"OK":function()
{
$("#open").dialog('destroy');
$.post("close.php?action=open",$("#newappointmentform").serialize(),function(data)
{
//debug
//alert(data);
},"text");
document.newappointmentform.reset();
$("#formWindow").dialog('destroy');
}
}
});
});
}