I patched twFile.js so there is a callback that guarantees twFile is fully 
initialized. It doesn't need to load any files at all. Use like this:

$.twFile.initialize().then(function() {
      alert('twFile is ready!');
});

Accomplished via jQuery Deferrred 
objects<http://intridea.com/2011/2/8/fun-with-jquery-deferred>(requires v1.5+).

Patch file attached; full twFile.js file at: http://jsbin.com/adehi5/edit







-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywikidev?hl=en.

--- jQuery.twFile.js	Sun May  8 13:56:34 2011
+++ twfile.js	Sun May  8 15:08:07 2011
@@ -78,6 +78,19 @@
 			return localPath || originalPath;
 		},
 
+		// Deferred initialization for any drivers that need it
+		// returns a Deferred object so callback that executes as soon
+		// as twFile is ready can be attached
+		initialize: function() {
+			return $.Deferred(function(dfd) {
+				for(var t in drivers) {
+					if(drivers[t].deferredInit)
+						drivers[t].deferredInit();
+				}
+				dfd.resolve();
+			});
+		},
+
 		// Private functions
 
 		// Returns a reference to the current driver
@@ -92,12 +105,9 @@
 		}
 	});
 
-	// Deferred initialisation for any drivers that need it
+	// Automatically initialize on document.ready()
 	$(function() {
-		for(var t in drivers) {
-			if(drivers[t].deferredInit)
-				drivers[t].deferredInit();
-		}
+		$.twFile.initialize();
 	});
 
 	// Private driver implementations for each browser

Reply via email to