SeanDagger
MIS
I have a small problem with a JavaScript function which is giving bizarre results.
I am working with SalesForce S-controls. The primary language used to create the pages is JavaScript.
I am displaying a page where data is queried from a database and displayed. (This function is called on an onchange of a selectbox). I have a function which:
1) Unhides a div displaying "Loading - Please wait"
2) Gets the data from the database
3) Calls other functions such as display data
4) Once data loaded, hide the div again.
The strange thing happening is that it will only work if I put an alert in the code (see code below). With the alert pop up, it shows the div, gets the data, and hides the div when data is displayed. If I comment out the alert call, it does not show or hide the div again, but the page will still display the results.
Is there anyway to simulate an alert action without popping up a message? (no user interaction needed)? I'm banging my head on this as very confusing.
My code is as follows:
function renderPage() {
document.getElementById("loadingAlert").innerHTML = "Loading new data - Please wait.";
alert('show the loading alert whilst getting data');
top.events = new Array();
top.eventsMatrix = new Array();
top.maxEvents = 2;
top.firstEventHour = 8;
top.lastEventHour = 20;
top.tasks = new Array();
sforce.connection.init("{!API.Session_ID}", "{!API.Enterprise_Server_URL_90}");
document.getElementById("devName").innerHTML = top.devName;
document.getElementById("calendarDate").innerHTML = getFormattedCalendarDate(top.selecteddate);
for (var i = 0; i < 50; i++) {
top.eventsMatrix = new Array()
for (var j = 0; j < 50; j++) {
top.eventsMatrix[j] = 0;
}
}
var t = 0;
for (var i = 0; i < 50; i++) {
if (i % 2 == 0) {
top.events[t + ":00"] = new Array();
} else {
top.events[t + ":30"] = new Array();
t++;
}
}
getEvents();
displayEvents();
getTasks();
displayTasks();
createHoverDivs();
alert('got the data - now hide loading alert');
document.getElementById("loadingAlert").innerHTML = "";
}
I am working with SalesForce S-controls. The primary language used to create the pages is JavaScript.
I am displaying a page where data is queried from a database and displayed. (This function is called on an onchange of a selectbox). I have a function which:
1) Unhides a div displaying "Loading - Please wait"
2) Gets the data from the database
3) Calls other functions such as display data
4) Once data loaded, hide the div again.
The strange thing happening is that it will only work if I put an alert in the code (see code below). With the alert pop up, it shows the div, gets the data, and hides the div when data is displayed. If I comment out the alert call, it does not show or hide the div again, but the page will still display the results.
Is there anyway to simulate an alert action without popping up a message? (no user interaction needed)? I'm banging my head on this as very confusing.
My code is as follows:
function renderPage() {
document.getElementById("loadingAlert").innerHTML = "Loading new data - Please wait.";
alert('show the loading alert whilst getting data');
top.events = new Array();
top.eventsMatrix = new Array();
top.maxEvents = 2;
top.firstEventHour = 8;
top.lastEventHour = 20;
top.tasks = new Array();
sforce.connection.init("{!API.Session_ID}", "{!API.Enterprise_Server_URL_90}");
document.getElementById("devName").innerHTML = top.devName;
document.getElementById("calendarDate").innerHTML = getFormattedCalendarDate(top.selecteddate);
for (var i = 0; i < 50; i++) {
top.eventsMatrix = new Array()
for (var j = 0; j < 50; j++) {
top.eventsMatrix[j] = 0;
}
}
var t = 0;
for (var i = 0; i < 50; i++) {
if (i % 2 == 0) {
top.events[t + ":00"] = new Array();
} else {
top.events[t + ":30"] = new Array();
t++;
}
}
getEvents();
displayEvents();
getTasks();
displayTasks();
createHoverDivs();
alert('got the data - now hide loading alert');
document.getElementById("loadingAlert").innerHTML = "";
}