Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Queue callbacks while requesting #9

Closed
wants to merge 1 commit into from

1 participant

@joeflateau

If a few widgets load the same data, they should all be notified when the data is loaded. Previously only the first widget's callback would be called.

@joeflateau joeflateau closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 9, 2012
  1. @joeflateau
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/jquery.offline.js
View
11 lib/jquery.offline.js
@@ -48,18 +48,17 @@
var requestingKey = url + "?" + $.param(data || {});
if (requesting[requestingKey]) {
+ requesting[requestingKey].push(fn);
return false;
}
- requesting[requestingKey] = true;
+ requesting[requestingKey] = [fn];
return jQuery.ajax({
type: "GET",
url: url,
data: data,
success: function(responseData, text) {
- delete requesting[requestingKey];
-
// handle lack of response (error callback isn't called in this case)
if (undefined === responseData) {
if (!window.navigator.onLine) {
@@ -71,9 +70,11 @@
return;
}
- fn(responseData, text);
+ $.each(requesting[requestingKey], function (i, fn) {
+ fn(responseData, text);
+ });
},
- error: function() {
+ complete: function() {
delete requesting[requestingKey];
},
dataType: "json",
Something went wrong with that request. Please try again.