Hi All
RESOLVED: The line destination.block(...) is the one causing the errors. I've forcing empty to equal true to avoid this. I think that the if (empty) statement is just picking between two different ways of displaying a busy message.
I'm new to jQuery and have taken over maintaining an ASP.NET MVC 2 project from an ex-colleague. I'm struggling to understand what the following line of code is doing:
var empty = ($(":not(script)", destination).length == 0);
This line causes and error in IE but not in Firefox. To be honest looking at the function below I don't think it's needed, but as my colleague did not believe in commenting his code. I need to understand the impact of changing the code. The context for the above is the following Javascript function:
PRISMbase.LoadPartialEx = function(url, data, destination, successCallback, loadingMessage, appendNotOverwrite) {
var empty = ($(":not(script)", destination).length == 0);
var message = loadingMessage == null ? "Please wait" : loadingMessage;
if (empty)
destination.html(busy);
else
destination.block({ message: '<h1 class="Progress">' + message + '</h1>' });
return $.ajax({
data: data,
dataType: "html", type: "GET", url: url,
success: function(viewHtml) {
var partial = $(viewHtml);
if (!empty)
destination.unblock();
if(viewHtml != "")
{
if (appendNotOverwrite)
destination.append(partial);
else
destination.html(partial);
PRISMbase.InitialiseFormElements(destination);
}
else
destination.empty();
if (successCallback != null) successCallback(destination, partial);
}
});
}
In the above:
destination = a jQuery selector returning "#TabContent" (this is a div).
busy ='<img class="progress" src="/Content/OnyxProgressCircle.gif" />';
Any help would be appreciated.
Thanks.
Alan