Stop interval if deleted
This commit is contained in:
@@ -353,10 +353,12 @@ class WSF_PROGRESS_CONTROL extends WSF_CONTROL
|
|||||||
self = @
|
self = @
|
||||||
runfetch= ()->
|
runfetch= ()->
|
||||||
self.fetch()
|
self.fetch()
|
||||||
setInterval(runfetch, 5000)
|
@int=setInterval(runfetch, 5000)
|
||||||
|
|
||||||
fetch: ()->
|
fetch: ()->
|
||||||
@trigger_callback(@control_name, 'progress_fetch')
|
@trigger_callback(@control_name, 'progress_fetch')
|
||||||
|
if @$el.closest('body').length <= 0
|
||||||
|
clearInterval(@int)
|
||||||
|
|
||||||
update: (state)->
|
update: (state)->
|
||||||
if state.progress?
|
if state.progress?
|
||||||
@@ -428,15 +430,13 @@ start_modal = (action)->
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
</div>
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
</div>
|
||||||
<button type="button" class="btn btn-primary">Save changes</button>
|
</div>""")
|
||||||
</div>
|
|
||||||
</div><!-- /.modal-content -->
|
|
||||||
</div><!-- /.modal-dialog -->
|
|
||||||
</div><!-- /.modal -->""")
|
|
||||||
modal.appendTo('body')
|
modal.appendTo('body')
|
||||||
modal.modal()
|
modal.modal('show')
|
||||||
|
modal.on 'hidden.bs.modal', ()->
|
||||||
|
modal.remove()
|
||||||
$.get( action.url, { ajax: 1 } )
|
$.get( action.url, { ajax: 1 } )
|
||||||
.done (data) ->
|
.done (data) ->
|
||||||
modal.find('.modal-body').append(data)
|
modal.find('.modal-body').append(data)
|
||||||
|
|||||||
@@ -638,11 +638,14 @@ WSF_PROGRESS_CONTROL = (function(_super) {
|
|||||||
runfetch = function() {
|
runfetch = function() {
|
||||||
return self.fetch();
|
return self.fetch();
|
||||||
};
|
};
|
||||||
return setInterval(runfetch, 5000);
|
return this.int = setInterval(runfetch, 5000);
|
||||||
};
|
};
|
||||||
|
|
||||||
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
||||||
return this.trigger_callback(this.control_name, 'progress_fetch');
|
this.trigger_callback(this.control_name, 'progress_fetch');
|
||||||
|
if (this.$el.closest('body').length <= 0) {
|
||||||
|
return clearInterval(this.int);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
||||||
@@ -756,9 +759,12 @@ show_alert = function(action) {
|
|||||||
|
|
||||||
start_modal = function(action) {
|
start_modal = function(action) {
|
||||||
var modal;
|
var modal;
|
||||||
modal = $("<div class=\"modal fade\">\n<div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n <h4 class=\"modal-title\">Modal title</h4>\n </div>\n <div class=\"modal-body\">\n \n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>\n <button type=\"button\" class=\"btn btn-primary\">Save changes</button>\n </div>\n </div><!-- /.modal-content -->\n</div><!-- /.modal-dialog -->\n</div><!-- /.modal -->");
|
modal = $("<div class=\"modal fade\">\n<div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n <h4 class=\"modal-title\">Modal title</h4>\n </div>\n <div class=\"modal-body\">\n \n </div>\n </div>\n</div>\n</div>");
|
||||||
modal.appendTo('body');
|
modal.appendTo('body');
|
||||||
modal.modal();
|
modal.modal('show');
|
||||||
|
modal.on('hidden.bs.modal', function() {
|
||||||
|
return modal.remove();
|
||||||
|
});
|
||||||
return $.get(action.url, {
|
return $.get(action.url, {
|
||||||
ajax: 1
|
ajax: 1
|
||||||
}).done(function(data) {
|
}).done(function(data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user