Implement remove

This commit is contained in:
YNH Webdev
2013-09-24 00:18:38 +02:00
parent 7e673b4628
commit 3f089d6811
2 changed files with 43 additions and 8 deletions

View File

@@ -139,6 +139,7 @@ WSF_CONTROL = (function() {
this.state = this.fullstate.state;
this.load_subcontrols();
this.isolation = "" + this.$el.data('isolation') === "1";
this.$el.data('control', this);
return;
}
@@ -287,6 +288,11 @@ WSF_CONTROL = (function() {
return this;
};
WSF_CONTROL.prototype.remove = function() {
console.log("Removed " + this.control_name);
return this.$el.remove();
};
return WSF_CONTROL;
})();
@@ -303,6 +309,7 @@ WSF_PAGE_CONTROL = (function(_super) {
this.control_name = this.state.id;
this.url = this.state['url'];
this.url_params = jQuery.unparam(this.state['url_params']);
this.$el.data('control', this);
this.load_subcontrols();
}
@@ -310,6 +317,11 @@ WSF_PAGE_CONTROL = (function(_super) {
return state;
};
WSF_PAGE_CONTROL.prototype.remove = function() {
console.log("Removed " + this.control_name);
return this.$el.remove();
};
return WSF_PAGE_CONTROL;
})(WSF_CONTROL);
@@ -642,10 +654,7 @@ WSF_PROGRESS_CONTROL = (function(_super) {
};
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
this.trigger_callback(this.control_name, 'progress_fetch');
if (this.$el.closest('body').length <= 0) {
return clearInterval(this.int);
}
return this.trigger_callback(this.control_name, 'progress_fetch');
};
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
@@ -655,6 +664,11 @@ WSF_PROGRESS_CONTROL = (function(_super) {
}
};
WSF_PROGRESS_CONTROL.prototype.remove = function() {
clearInterval(this.int);
return WSF_PROGRESS_CONTROL.__super__.remove.apply(this, arguments);
};
return WSF_PROGRESS_CONTROL;
})(WSF_CONTROL);
@@ -763,7 +777,9 @@ start_modal = function(action) {
modal.appendTo('body');
modal.modal('show');
modal.on('hidden.bs.modal', function() {
return modal.remove();
$(modal.find('[data-name]').get().reverse()).each(function(i, value) {
$(value).data('control').remove();
});
});
return $.get(action.url, {
ajax: 1