How to create a custom “confirm” & pause js execution until user clicks button?

前端 未结 6 900
后悔当初
后悔当初 2020-12-11 01:37

Ok, I\'m doing a bunch of RIA/AJAX stuff and need to create a \"pretty\", custom confirm box which is a DIV (not the built-in javascript confirm). I\'m having trouble determ

6条回答
  •  爱一瞬间的悲伤
    2020-12-11 02:31

    Check out my Fiddle modal alert box: http://jsfiddle.net/katiabaer/UXM9y/33/ with JqueryUI modal

       showAlert = function (msg, header, callback) {
          var mydiv = $("
    "); mydiv.alertBox({ message: msg, header: header, callback: callback }); }, $('#show').click(function () { var m = $('#message').val(); var h = $('#header').val(); var callback = function () { alert("I can do anything here"); } showAlert(m, h, callback); }); $.widget("MY.alertBox", { options: { message: "", header: "", callback: '' }, _create: function () { var self = this; self.callback = self.options.callback; self.container = $(".alert-messagebox"); var header = self.container.find(".alert-header"); header.html(self.options.header); var message = self.container.find(".alert-message"); message.html(self.options.message); var closeButton = self.container.find("button.modal-close-button"); closeButton.click(function () { self.close(); }); self.show(); }, show: function () { var self = this; self.container.modal({ maxWidth: 500 }); }, close: function () { if (this.callback != null) { this.callback(); $.modal.close(); return; } $.modal.close(); }, destroy: function () { $.Widget.prototype.destroy.call(this); } });

提交回复
热议问题