Given the code (a lot of it stripped out)
// A data set
$.DataArea = function() {
// Default options
$.extend(this, {
'class': "DataSet",
'bars': new Array(),
'container': null,
'containerId': null,
'gridsize': 20,
'width': 400,
'height': 400,
'currentSelectedBar': 0
});
// Add a bar to this object
this.addBar = function(startDate, endDate, label, styleID) {
// When the bar is clicked
$('#' + barID).click(function() {
alert($(this).currentSelectedBar);
if (this.currentSelectedBar != undefined)
$('#' + this.currentSelectedBar).fadeIn("slow");
this.currentSelectedBar = barID;
$('#' + barID).fadeTo("slow", 0.5);
});
}
When I alert($(this).currentSelectedBar); it always comes out as undefined, it's not setting the value properly. Any ideas why this might be?
The idea is when you click on a bar, it fades it out, and when you click another the last bar to fade out fades in as well.
Assuming you are calling addBar on an instance of DataArea, your code should be:
// Add a bar to this object
this.addBar = function(startDate, endDate, label, styleID) {
var self = this;
// When the bar is clicked
$('#' + barID).click(function() {
alert(self.currentSelectedBar);
if (self.currentSelectedBar != undefined)
$('#' + self.currentSelectedBar).fadeIn("slow");
self.currentSelectedBar = this.id;
$(this).fadeTo("slow", 0.5);
});
}
Inside the click handler, this will refer to the DOM element '#' + barID. But the properties are assigned to some other element and not that DOM element.
The this in your callback function refers to the element that rises the event : in that case $('#' + barID).
I guess you want to access the this that you extended. In that case, you should write something like that :
this.addBar = function(startDate, endDate, label, styleID) {
var self = this
// When the bar is clicked
$('#' + barID).click(function() {
alert($(self).currentSelectedBar);
if (self.currentSelectedBar != undefined)
$('#' + self.currentSelectedBar).fadeIn("slow");
self.currentSelectedBar = barID;
$(this).fadeTo("slow", 0.5);
});
}
var that = this;
$('#' + barID).click(function() {
alert(that.currentSelectedBar);
if (that.currentSelectedBar != undefined)
$('#' + this.currentSelectedBar).fadeIn("slow");
that.currentSelectedBar = barID;
$('#' + barID).fadeTo("slow", 0.5);
});
Cache the value of this outside the click function. inside the click function, the context this is the DOM node that was clicked.
It looks like you're having an issue with the behavior of jQuery.
$('#' + barID).click(function() { remaps the definition of this, but having attempted to add attributes to it previously will have no effect because the definition of this has been overwritten.
As mentioned by recmashak you can put the original this into a variable and then use it when you do your alert
Related
if (!slideOutObserver && doc.querySelector('.slide-out-cms')) {
mutObv.observe(doc.querySelector('.slide-out-cms'), { attributeFilter: ['class'] });
slideOutObserver = true;
}
The console error is as follows: script5022: SyntxError
Which I click on and it takes me to the above code
Any ideas or workarounds?
Entire script if needed, in this script we are showing the user a cookie consent message, which overlaps some fixed elements on the page. We are doing some other things to reposition and slide things up and down based on what elements are visible:
// On document ready
$(function() {
var cookieAckId = 'cookie-acknowledgment',
pureCloudId = 'chatTrigger',
slideOutClass = 'slide-out-cms.show',
mobileContinue = 'fixed-button-container',
slideOutObserver = false,
consentText = 'This site uses essential cookies to function correctly. For more detailed information, please see our privacy policy. By continuing to use this website you consent to our use of cookies.',
mutObv;
//If the user closes/accepts the acknowledgment
function closeAck() {
// Remove the Acknowledgment from the page and shift floaters back
$('#' + cookieAckId).slideUp().queue(function() {
$(this).remove();
repositionFloaters();
});
//Kill Mutation Observer
mutObv.disconnect();
//Kill the resize listener
$(root).off('resize', repositionFloaters);
//set cookie
var d = new Date;
d.setFullYear(d.getFullYear() + 2);
$.cookie('acceptedGdprCookies', 'true', {
path: '/',
domain: '.' + browser.getDomain(),
expires: d,
});
}
// floaters are there, let's alter their position!
function repositionFloaters() {
var $cookieAck = $('#' + cookieAckId),
cookieAckHeight = 0,
$pureCloud = $('#' + pureCloudId),
$slideOut = $('.' + slideOutClass),
$mobileContinue = $('.' + mobileContinue);
if (!slideOutObserver && doc.querySelector('.slide-out-cms')) {
mutObv.observe(doc.querySelector('.slide-out-cms'), { attributeFilter: ['class'] });
slideOutObserver = true;
}
// If cookie Acknowledgment exists, grab it's height
if ($cookieAck.length) {
cookieAckHeight = $cookieAck.outerHeight();
}
// Shift up Purecloud and Slide Out if they exist
[$pureCloud, $slideOut, $mobileContinue].forEach(function($item) {
if ($item.length) {
$item.css('transform', 'translateY(-' + cookieAckHeight + 'px)');
}
});
// If both Slideout and purecloud exist, stop trying to observe for their addition
if ($pureCloud.length && $slideOut.length && cookieAckHeight > 0) {
mutObv.disconnect();
}
}
// Create the Cookie Acknowledgment
var $cookieAck = $('<div id="' + cookieAckId + '"><div class="relative"><div class="ca-text col-xs-12"><span>' + consentText + '</span><div class="ca-accept"></div></div></div>'),
$acceptBtn = $('<button class="ca-accept-btn b">ACCEPT</button>').on('click', closeAck),
$closeBtn = $('<span class="ca-close-btn icon-closepositive"></span>').on('click', closeAck);
$cookieAck.append($closeBtn);
$cookieAck.find('.ca-accept').append($acceptBtn);
$('body').append($cookieAck);
// Create Mutation Observer to watch for Purecloud and Slideout being added to the page
mutObv = new MutationObserver(repositionFloaters);
mutObv.observe(doc.body, { childList: true });
// Add Listener if the page is resized
$(root).on('resize', repositionFloaters);
// Upon creating of Cookie Acknowledgment element, try to shift floaters
repositionFloaters();
});
If anyone is happens to need the answer for this, I finally solved it!
MS Edge does not like the mutation observer without the argument attributes: true.
So the correct code would look like this:
if (!slideOutObserver && doc.querySelector('.slide-out-cms')) {
mutObv.observe(doc.querySelector('.slide-out-cms'), {
attributes: true,
attributeFilter: ['class']
});
}
I am trying to combine these two functions into one. I know there has to be a really simple way to do it, but everything I have tried so far has not worked. Essentially there are two icons and two menus. When you click one icon a menu either drops down (or raises) depending on the state they are in. Everything after the variables is the same, so it seems to make sense to consolidate them into one shared function. Any help would be greatly appreciated. Thanks!
$(function(){
///Manage Icon 1
$('.ecGlobalNavStudentIcon').click(function(e){
var n = 'hideme'
var m = $('#ecGlobalNavStudentPanel')
var p = $('#ecGlobalNavStaffPanel')
e.preventDefault(); //just prevent the default behavior of the hyperlink
if(m.hasClass(n)) {
console.log($(m).attr('id') + " Has 'hideme' gonna open up");
$(m).show().removeClass(n);
$(m).animate({
height:'49px'
},
500, // Duration
function() { // Callback when the animation is finished
console.log($(m).attr('id') + " Opened!");
});
} else {
console.log($(m).attr('id') + " didn't have 'hideme' gonna try and
close. ");
$(m).animate({
height:'0px'
},
500, // Duration
function() { // Callback when the animation is finished
$(m).hide().addClass(n);
console.log($(m).attr('id') + " Closed!");
});
}
if(!$(p).hasClass(n)) {//open
console.log($(p).attr('id') + " panel open! Gonna close.");
$(p).animate({//close
height:'0px'
},//close
500, // Duration
function() { // Callback when the animation is finished /open
console.log($(p).attr('id') + " Closed by animation!");
$(p).hide().addClass(n);
});//close
}
});
///Manage Icon 2
$('.ecGlobalNavStaffIcon').click(function(e){
var n = 'hideme'
var m = $('#ecGlobalNavStaffPanel')
var p = $('#ecGlobalNavStudentPanel')
e.preventDefault(); //just prevent the default behavior of the hyperlink
if (m.hasClass(n)) {
console.log($(m).attr('id') + " Has 'hideme' gonna open up");
$(m).show().removeClass(n);
$(m).animate({
height: '49px'
},
500, // Duration
function () { // Callback when the animation is finished
console.log($(m).attr('id') + " Opened!");
});
} else {
console.log($(m).attr('id') + " didn't have 'hideme' gonna try and close. ");
$(m).animate({
height: '0px'
},
500, // Duration
function () { // Callback when the animation is finished
$(m).hide().addClass(n);
console.log($(m).attr('id') + " Closed!");
});
}
if (!$(p).hasClass(n)) {//open
console.log($(p).attr('id') + " panel open! Gonna close.");
$(p).animate({//close
height: '0px'
},//close
500, // Duration
function () { // Callback when the animation is finished /open
console.log($(p).attr('id') + " Closed by animation!");
$(p).hide().addClass(n);
});//close
}
});
});
If you want to handle same event for multiple selectors, use the selectors as comma separated.. In your case
$('.ecGlobalNavStudentIcon, .ecGlobalNavStaffIcon').click(function(){
//Your common event handler
});
Always remember, repeating code is evil, a sign of some mistake you've made. And you have done a great job finding it :) Happy coding
It is always good to separate DOM event handling and actual logic.
icon1 click and icon2 click triggers event A
on event A do action A'
consider this example:
$(body).on('togglePanels.my', function (e, activePanel ) {
var panels = $('.panels')
panels.removeClass(cssClass)
activePanel.addClass(cssClass)
})
$(body).on('click','.panelHeader' function(e) {
var $this= $(this)
, panel = $('#' + $this.data('target'))
$(body).trigger('togglePanels.my', [panel])
})
This is pretty much all code you need for accordion you are building, with exception of animation effects
Notice that it requires you to slightly change markup:
common .panel class added for panels
another one .panelHeader for icons
icon has data-target attribute with ID of panel to open.
instead of hide-me class to hide panel, cssClass should hold name of css class to open active one
example markup:
<div>
<i class="panelHeader ecGlobalNavStudentIcon"
data-target="ecGlobalNavStudentPanel">Student</i>
<i class="panelHeader ecGlobalNavStuffIcon"
data-target="ecGlobalNavStaffPanel">Stuff</i>
</div>
<div id='ecGlobalNavStudentPanel'
class="panel ecGlobalNavStudentPanel">...</div>
<div id='ecGlobalNavStaffPanel'
class="panel ecGlobalNavStaffPanel">...</div>
Something like this would work:
$('.ecGlobalNavStudentIcon, .ecGlobalNavStaffIcon').click(function(e){
var n = 'hideme'
var m = $(e.target).hasClass('ecGlobalNavStudentIcon') ? $('#ecGlobalNavStudentPanel') : $('#ecGlobalNavStaffPanel');
var p = $(e.target).hasClass('ecGlobalNavStudentIcon') ? $('#ecGlobalNavStaffPanel') : $('#ecGlobalNavStudentPanel');
$('.ecGlobalNavStaffIcon, ecGlobalNavStaffIcon').click(function(e){
var n = 'hideme';
if this.hasClass('ecGlobalNavStaffIcon'){
var m = $('#ecGlobalNavStudentPanel')
var p = $('#ecGlobalNavStaffPanel')
}
else {
var m = $('#ecGlobalNavStaffPanel')
var p = $('#ecGlobalNavStudentPanel')
}
...
}
if you need, just apply a param and then use the same code (example: $('#'+myParamToSelect).function()
I have a modal box in jQuery which I have created to display some embed code. I want the script to take the id of the link that is clicked but I can't seem to get this working.
Does anyone know how I can do that or why this may be happening?
My jQuery code is:
function generateCode() {
var answerid = $('.openembed').attr('id');
if($('#embed input[name="comments"]:checked').length > 0 == true) {
var comments = "&comments=1";
} else {
var comments = "";
}
$("#embedcode").html('<code><iframe src="embed.php?answerid=' + answerid + comments + '" width="550" height="' + $('#embed input[name="size"]').val() + '" frameborder="0"></iframe></code>');
}
$(document).ready(function () {
$('.openembed').click(function () {
generateCode();
var answerid = $('.openembed').attr('id');
$('#box').show();
return false;
});
$('#embed').click(function (e) {
e.stopPropagation()
});
$(document).click(function () {
$('#box').hide()
});
});
My mark-up is:
Embed
Embed
Your problem is here:
$('.openembed')
returns an array of matched elements. Your should instead select only the clicked element.
$('.openembed') works correctly if you assing a click event to all elements that have this class. But on the other hand, you're unable do know which is clicked.
But fortunately in the body of handler function click you could call $(this).
$(this) will return the current (and clicked element).
// var answerid = $('.openembed').attr('id'); // Wrong
var answerid = $(this).attr('id'); // Correct
// Now you can call generateCode
generateCode(answerid);
Another error is the body of generateCode function. Here you should pass the id of selected element. This is the correct implementation.
function generateCode(answerid) {
if($('#embed input[name="comments"]:checked').length > 0 == true) {
var comments = "&comments=1";
} else {
var comments = "";
}
$("#embedcode").html('<iframe src="embed.php?answerid=' + answerid + comments + '" width="550" height="' + $('#embed input[name="size"]').val() + '"frameborder="0"></iframe>');
}
Here I have implemented your code with the correct behavior: http://jsfiddle.net/pSZZF/2/
Instead of referencing the class, which will grab all members of that class, you need to reference $(this) so you can get that unique link when it is clicked.
var answerid = $(this).prop('id');
$('.openembed').click(function () {
generateCode();
var answerid = $(this).attr('id');
$('#box').show();
return false;
});
Use $(this). $('.openembed') refers to multiple links.
var answerid = $('.openembed').attr('id');
needs to be
var answerid = $(this).prop('id');
The other answers are trying to fix the click() function, but your issue is actually with the generateCode function.
You need to pass the clicked element to the generateCode function:
$('.openembed').click(function () {
generateCode(this);
And modify generateCode:
function generateCode(element) {
var answerid = element.id;
Of course var answerid = $('.openembed').attr('id'); within the click code isn't correct either, but it doesn't seem to do anything anyway.
Get the id when the correct anchor is clicked and pass it into your generateCode function
$('.openembed').click(function () {
var answerid = $(this).attr('id');
generateCode(answerid)
$('#box').show();
return false;
});
Change your function
function generateCode(answerid) {
// dont need this line anymore
// var answerid = $('.openembed').attr('id');
I'm using the following placeholder plugin
(function($){
var ph = "PLACEHOLDER-INPUT";
var phl = "PLACEHOLDER-LABEL";
var boundEvents = false;
var default_options = {
labelClass: 'placeholder'
};
//check for native support for placeholder attribute, if so stub methods and return
var input = document.createElement("input");
if ('placeholder' in input) {
$.fn.placeholder = $.fn.unplaceholder = function(){}; //empty function
delete input; //cleanup IE memory
return;
};
delete input;
//bind to resize to fix placeholders when the page resizes (fields are hidden/displayed, which can change positioning).
$(window).resize(checkResize);
$.fn.placeholder = function(options) {
bindEvents();
var opts = $.extend(default_options, options)
this.each(function(){
var rnd=Math.random().toString(32).replace(/\./,'')
,input=$(this)
,label=$('<label style="position:absolute;display:none;top:0;left:0;"></label>');
if (!input.attr('placeholder') || input.data(ph) === ph) return; //already watermarked
//make sure the input tag has an ID assigned, if not, assign one.
if (!input.attr('id')) input.attr('id', 'input_' + rnd);
label .attr('id',input.attr('id') + "_placeholder")
.data(ph, '#' + input.attr('id')) //reference to the input tag
.attr('for',input.attr('id'))
.addClass(opts.labelClass)
.addClass(opts.labelClass + '-for-' + this.tagName.toLowerCase()) //ex: watermark-for-textarea
.addClass(phl)
.text(input.attr('placeholder'));
input
.data(phl, '#' + label.attr('id')) //set a reference to the label
.data(ph,ph) //set that the field is watermarked
.addClass(ph) //add the watermark class
.after(label) //add the label field to the page
//setup overlay
itemFocus.call(this);
itemBlur.call(this);
});
};
$.fn.unplaceholder = function(){
this.each(function(){
var input=$(this),
label=$(input.data(phl));
if (input.data(ph) !== ph) return;
label.remove();
input.removeData(ph).removeData(phl).removeClass(ph).unbind('change',itemChange);
});
};
function bindEvents() {
if (boundEvents) return;
//prepare live bindings if not already done.
$("form").live('reset', function(){
$(this).find('.' + ph).each(itemBlur);
});
$('.' + ph)
.live('keydown',itemFocus)
.live('mousedown',itemFocus)
.live('mouseup',itemFocus)
.live('mouseclick',itemFocus)
.live('focus',itemFocus)
.live('focusin',itemFocus)
.live('blur',itemBlur)
.live('focusout',itemBlur)
.live('change',itemChange);
;
$('.' + phl)
.live('click', function() { $($(this).data(ph)).focus(); })
.live('mouseup', function() { $($(this).data(ph)).focus(); });
bound = true;
boundEvents = true;
};
function itemChange() {
var input = $(this);
if (!!input.val()) {
$(input.data(phl)).hide();
return;
}
if (input.data(ph+'FOCUSED') != 1) {
showPHL(input);
}
}
function itemFocus() {
$($(this).data(ph+'FOCUSED',1).data(phl)).hide();
};
function itemBlur() {
var that = this;
showPHL($(this).removeData(ph+'FOCUSED'));
//use timeout to let other validators/formatters directly bound to blur/focusout work
setTimeout(function(){
var input = $(that);
//if the item wasn't refocused, test the item
if (input.data(ph+'FOCUSED') != 1) {
showPHL(input);
}
}, 200);
};
function showPHL(input, forced) {
var label = $(input.data(phl));
//if not already shown, and needs to be, show it.
if ((forced || label.css('display') == 'none') && !input.val())
label
.text(input.attr('placeholder'))
.css('top', input.position().top + 'px')
.css('left', input.position().left + 'px')
.css('display', 'block');
//console.dir({ 'input': { 'id':input.attr('id'), 'pos': input.position() }});
}
var cr;
function checkResize() {
if (cr) window.clearTimeout(cr);
cr = window.setTimeout(checkResize2, 50);
}
function checkResize2() {
$('.' + ph).each(function(){
var input = $(this);
var focused = $(this).data(ph+'FOCUSED');
if (!focused) showPHL(input, true);
});
}
}(jQuery));
It applies the placeholder attribute to form fields in browsers that do not natively support the placeholder attribute (ex. IE9). It works for statically loaded text fields, however for text fields that are loaded via ajax, the placeholder does not appear.
Is it possible to achieve this 'watermark' effect on text fields that are loaded via ajax?
What happens if you trigger the window resize function after adding in new inputs?
$(window).trigger('resize')
You could apply the plugin to newly created controls after the AJAX call completes. Forgive the pseudo-code as I'm not really sure about how your AJAX calls are working:
$.ajax({
url: "test.html",
cache: false
}).done(function( result ) {
field = $('<input>').html(result);
$("#results").append(field);
field.placeholder();
});
Another option is that you could use jQuery's .on() method to bind dynamically created controls to the function--but it wants an event (like click). I'm not sure how you would do that. Maybe something like this:
$( 'body' ).on('click','input.addField', function(e){
$(this).placeholder();
});
I know this won't work, but maybe it helps get you brainstorm solutions.
I'm trying to display a progress bar while ajax calls populate a form. I have a function called LOADFORM(). It launches a jquery dialog box, displays a progress bar, calles a few other non-async ajax calls to get data. With each data call complete it advances the progress bar and at the end it hides the progressbar and displays the form. This works perfecly in Firfox, but in IE, it just shows the completed form. I doesn't update the UI until the function is done running and by that time everything is complete, but the user has to sit at a uneventful screen for several seconds. How do I make the UI in IE 8 update as lines of JavaScript are executed in a function?
Example:
ActionReportForms.prototype.LoadFormData = function (constId, formType) {
//HOOK UP DATE PICKER
$('#' + this.TPLDATEFIELD_ID).datepicker();
$('#' + this.CRDATEFIELD_ID).datepicker();
//CLEAR FIELDS
this.ClearFormFields();
//HIDE ERRORS
this.ShowError(false, "");
//SHOW PROGRESS BAR
this.ShowProgress(true, 30, "loading...");
this.ShowDialogBox();
//POPULATE FIELDS
this.GetAccountName(constId);
this.ShowProgress(true, 60, "loading...proposals");
this.GetProposlas(constId);
this.ShowProgress(true, 90, "loading...action types");
this.GetActionTypes();
this.ShowProgress(true, 100, "loading...complete");
this.ConstituentID = constId;
$("#" + this.CONSTITUENTID_ID + ":input").val("");
$("#" + this.CONSTITUENTID_ID + ":input").val(constId);
//HIDE
$('#' + this.TPLDATEFIELD_ID).datepicker("hide");
$('#' + this.CRDATEFIELD_ID).datepicker("hide");
//TOGGLE FORM
if (formType != "") {
ToggleForms(formType);
}
//HIDE PROGRESS BAR
this.ShowProgress(false, 0, "");
}
Thanks,
T
You could chain the different stages together with window.setTimout(). This gives the browser a little time to redraw the page. In this example I set the timeout to 1ms. I am not shure if that will do the trick. Note that I start the chain at the end of the outer function.
ActionReportForms.prototype.LoadFormData = function (constId, formType) {
//HOOK UP DATE PICKER
$('#' + this.TPLDATEFIELD_ID).datepicker();
$('#' + this.CRDATEFIELD_ID).datepicker();
//CLEAR FIELDS
this.ClearFormFields();
//HIDE ERRORS
var hideErrors = function()
{
this.ShowError(false, "");
window.setTimeout(showProgessBar, 1);
};
//SHOW PROGRESS BAR
var showProgressBar = function()
{
this.ShowProgress(true, 30, "loading...");
this.ShowDialogBox();
window.setTimeout(populateFields, 1);
};
//POPULATE FIELDS
var populateFields = function()
{
this.GetAccountName(constId);
this.ShowProgress(true, 60, "loading...proposals");
window.setTimeout(loadProposals, 1);
};
var loadProposals = function()
{
this.GetProposlas(constId);
this.ShowProgress(true, 90, "loading...action types");
window.setTimeout(loadActionTypes, 1);
};
var loadActionTypes = function()
{
this.GetActionTypes();
this.ShowProgress(true, 100, "loading...complete");
this.ConstituentID = constId;
$("#" + this.CONSTITUENTID_ID + ":input").val("");
$("#" + this.CONSTITUENTID_ID + ":input").val(constId);
//HIDE
$('#' + this.TPLDATEFIELD_ID).datepicker("hide");
$('#' + this.CRDATEFIELD_ID).datepicker("hide");
//TOGGLE FORM
if (formType != "") {
ToggleForms(formType);
}
//HIDE PROGRESS BAR
this.ShowProgress(false, 0, "");
};
// Start with hide errors.
hideErrors();
};
Chaining via callbacks. Its all about the callbacks. I've been avoiding them because they're ugly and hard to read, but they allow you update the DOM while the rest of your code runs, IN IE. This is un
function LoadFormCall(constId, formType) {
//HOOK UP DATE PICKER
$('#' + this.TPLDATEFIELD_ID).datepicker();
$('#' + this.CRDATEFIELD_ID).datepicker();
arfObj.hiddenStuff1 = constId;
arfObj.hiddenStuff2 = formType;
//CLEAR FIELDS
arfObj.ClearFormFields();
//HIDE ERRORS
arfObj.ShowError(false, "");
//SHOW PROGRESS BAR
arfObj.ShowProgress(true, 30, "loading...");
//OPEN DIALOG
ShowDialogBox();
//POPULATE FIELDS
//THIS CALLS A JQUERY $.ajax call with a callback execute in the success function
//AND SO BEGINS THE CHAIN.
arfObj.GetAccountName1(constId, LoadFormCall2);
};
function LoadFormCall2() {
constId = arfObj.hiddenStuff1;
arfObj.ShowProgress(true, 60, "loading...proposals");
arfObj.GetProposals1(constId, LoadFormCall3);
};
function LoadFormCall3() {
arfObj.ShowProgress(true, 90, "loading...action types");
arfObj.GetActionTypes1(LoadFormCall4);
}
function LoadFormCall4(){
arfObj.ShowProgress(true, 100, "loading...complete");
arfObj.ConstituentID = constId;
$("#" + arfObj.CONSTITUENTID_ID + ":input").val("");
$("#" + arfObj.CONSTITUENTID_ID + ":input").val(constId);
//HIDE
$('#' + arfObj.TPLDATEFIELD_ID).datepicker("hide");
$('#' + arfObj.CRDATEFIELD_ID).datepicker("hide");
//TOGGLE FORM
if (arfObj.hiddenStuff2 != "") {
ToggleForms(arfObj.hiddenStuff2);
}
//HIDE PROGRESS BAR
arfObj.ShowProgress(false, 0, "");
}
This only appears to work in Firefox because it fakes synchronous XMLHttpRequest using asynchronous XMLHttpRequest. And while it's waiting for the request to complete, it updates the screen, because it hasn't got anything better to do.
But really, you should stop using synchronous XMLHttpRequest.