Blame view

assets/js/ace/ace.widget-on-reload.js 1.01 KB
5a739853   patrick.he   commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  /**
   The widget box reload button/event handler. You should use your own handler. An example is available at <i class="text-info">examples/widgets.html</i>.
   <u><i class="glyphicon glyphicon-flash"></i> You don't need this. Used for demo only</u>
  */
  
  (function($ , undefined) {
  
  	//***default action for reload in this demo
  	//you should remove this and add your own handler for each specific .widget-box
  	//when data is finished loading or processing is done you can call $box.trigger('reloaded.ace.widget')
  	$(document).on('reload.ace.widget', '.widget-box', function (ev) {
  		var $box = $(this);
  		
  		//trigger the reloaded event to remove the spinner icon after 1-2 seconds
  		setTimeout(function() {
  			$box.trigger('reloaded.ace.widget');
  		}, parseInt(Math.random() * 1000 + 1000));
  	});
  
  	//you may want to do something like this:
  	/**
  	$('#my-widget-box').on('reload.ace.widget', function(){
  		//load new data here
  		//and when finished trigger "reloaded" event
  		$(this).trigger('reloaded.ace.widget');
  	});
  	*/
  })(window.jQuery);