Sha256: 4ee44db2881b85105a27dd87ea05cf47014db8fd488b6e961c6c35a04f7ebd6f

Contents?: true

Size: 728 Bytes

Versions: 11

Compression:

Stored size: 728 Bytes

Contents

// this allows culerity to wait until all ajax requests have finished
jQuery(function($) {
	var original_ajax = $.ajax;
	var count_down = function(callback) {
		return function() {
			try {
				if(callback) {
					callback.apply(this, arguments);
				};
			} catch(e) {
				window.running_ajax_calls -= 1;
				throw(e);
			}
			window.running_ajax_calls -= 1;
		};
	};
	window.running_ajax_calls = 0;
	
	var ajax_with_count = function(options) {
		if(options.async == false) {
		  return(original_ajax(options));
		} else {
			window.running_ajax_calls += 1;
			options.success = count_down(options.success);
			options.error = count_down(options.error);
			return original_ajax(options);
		}
	};

	$.ajax = ajax_with_count;
});

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
culerity-0.2.15 rails_generators/culerity/templates/public/javascripts/culerity.js
culerity-0.2.14 rails_generators/culerity/templates/public/javascripts/culerity.js
culerity-0.2.13 rails_generators/culerity/templates/public/javascripts/culerity.js
culerity-0.2.12 rails_generators/culerity/templates/public/javascripts/culerity.js
culerity-0.2.10 rails_generators/culerity/templates/public/javascripts/culerity.js
fletcherm-culerity-0.2.9 rails_generators/culerity/templates/public/javascripts/culerity.js
culerity-0.2.9 rails_generators/culerity/templates/public/javascripts/culerity.js
fletcherm-culerity-0.2.8 rails_generators/culerity/templates/public/javascripts/culerity.js
culerity-0.2.8 rails_generators/culerity/templates/public/javascripts/culerity.js
fletcherm-culerity-0.2.7 rails_generators/culerity/templates/public/javascripts/culerity.js
culerity-0.2.7 rails_generators/culerity/templates/public/javascripts/culerity.js