How to create jQuery Dialog in function

后端 未结 3 1328
抹茶落季
抹茶落季 2021-02-05 11:01

Does anyone know how to create a jQuery Dialog in a function? I can\'t find an attribute to set the message... In every example I found, the dialog has been statically written i

3条回答
  •  伪装坚强ぢ
    2021-02-05 11:57

    I used this with additionally jQuery tmpl plugin.

    var confirmTemplate = jQuery.template("

    ${text}

    "); function showDialog(options) { if (options && options.data && options.dialog) { var dialogOptions = jQuery.extend({}, { modal: true, resizable: false, draggable: false }, options.dialog); return jQuery.tmpl(confirmTemplate, options.data).dialog(dialogOptions); } } function hideDialog (item) { if (!item.jQuery) item = $(item); item.dialog("close").dialog("destroy").remove(); }

    usage:

    showDialog({
                 data: {
                          title: "My Title",
                          text: "my Text"
                       }
                 dialog: {
                         myDialog: "options"
                 }
               });
    

提交回复
热议问题