var AlertMSG = function(){ this.$modal = $(''); this.$modal.appendTo('body'); this.$modal.find('.close').on('click',function(){ this.$modal.modal('hide'); }); return this; }; AlertMSG.prototype={ showAlert: function(_options){ var options={ msg:'', callback: null }; options = $.extend(options, _options); this.$modal.find('.modal-body').html(options.msg); this.$modal.modal('show'); (options.callback && typeof(options.callback) === "function") && options.callback(); }, hideAlert: function(){ this.$modal.modal('hide'); this.$modal.find('.modal-body').html(''); } }