Permalink
Browse files

version 0.2

  • Loading branch information...
1 parent a4acd56 commit edc18cd1d6b7c0bc0ab3179255abdd334428bc27 @jfragoulis committed Nov 5, 2012
Showing with 12 additions and 4 deletions.
  1. +11 −3 assets/jquery.metabox.js
  2. +1 −1 assets/jquery.metabox.min.js
View
@@ -10,6 +10,11 @@
this.$element = $(element)
this.options = $.extend({}, $.fn.metabox.defaults, options)
+ if(this.options.loadingContainer)
+ this.options.loadingContainer = $(this.options.loadingContainer);
+ else
+ this.options.loadingContainer = this.$element;
+
if(this.options.refreshTimeout>0)
this.createTimeout();
@@ -56,12 +61,12 @@
data : this.options.data,
beforeSend : function() {
$box.$element.addClass($box.options.loadingClass);
- $box.$element.hide().next().show();
+ $box.options.loadingContainer.html($box.options.loadingText);
$box.options.beforeRefresh.apply($box);
},
success : function(data) {
$box.$element.removeClass($box.options.loadingClass);
- $box.$element.show().next().hide();
+ $box.options.loadingContainer.html('');
$box.options.handleResponse.apply($box, [data])
$box.options.afterRefresh.apply($box, [data]);
},
@@ -128,14 +133,17 @@
$.fn.metabox.defaults = {
loadingText: 'loading...',
loadingClass: 'metabox-loading',
+ loadingContainer: null,
url: null,
data : {},
type : 'GET',
refreshOnInit : false,
refreshTimeout : 0,
refreshInterval : 0,
beforeRefresh: function() {},
- handleResponse: function(data) {this.$element.html(data);},
+ handleResponse: function(data) {
+ this.$element.html(data);
+ },
afterRefresh: function(data) {}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit edc18cd

Please sign in to comment.