diff --git a/js/sco.modal.js b/js/sco.modal.js index 2753148..7ba3cee 100644 --- a/js/sco.modal.js +++ b/js/sco.modal.js @@ -113,6 +113,9 @@ ,close: function() { this.$modal.hide().off('.' + pluginName).find('.inner').html(''); + if (this.options.cssclass !== undefined) { + this.$modal.removeClass(this.options.cssclass); + } $(document).off('keyup.' + pluginName); $('.modal-backdrop').remove(); if (typeof this.options.onClose === 'function') { diff --git a/tests/unit/sco.modal.js b/tests/unit/sco.modal.js index 131ba44..3f46ef0 100644 --- a/tests/unit/sco.modal.js +++ b/tests/unit/sco.modal.js @@ -44,6 +44,27 @@ $(function () { $modal.destroy(); }); + test('cssclass should be removed between different modals using the same modal block', function() { + var $modal = $.scojs_modal({ + content: 'abcd' + ,cssclass: 'test' + ,appendTo: '#qunit-fixture' + }).show(); + ok($('#qunit-fixture #modal').hasClass('test'), 'class exists'); + $('#qunit-fixture #modal .close').trigger('click'); + ok(!$('#qunit-fixture #modal').hasClass('test'), 'class doesn\'t exists after close'); + var $modal = $.scojs_modal({ + content: 'abcd' + ,cssclass: 'foo' + ,appendTo: '#qunit-fixture' + }).show(); + ok(!$('#qunit-fixture #modal').hasClass('test'), 'old class doesn\'t exists in the new modal'); + ok($('#qunit-fixture #modal').hasClass('foo'), 'new class exists'); + $('#qunit-fixture #modal .close').trigger('click'); + ok(!$('#qunit-fixture #modal').hasClass('foo'), 'class doesn\'t exists after close'); + $modal.destroy(); + }); + module('modal data-api');