开发者

jQuery UI Plugin to append dialogs to form tag in ASP.NET

开发者 https://www.devze.com 2023-03-17 01:58 出处:网络
How would I make a jQuery plugin that does the following: var login = $(\"#login-dialog\"); login 开发者_运维百科.dialog({ autoOpen: false })

How would I make a jQuery plugin that does the following:

        var login = $("#login-dialog");

        login
  开发者_运维百科          .dialog({ autoOpen: false })
            .parent(".ui-dialog")
            .appendTo("form");

but returns the same as .dialog would return (that is, $("#login-dialog") again)

so I could use

login.dialogForm({ autoOpen: false}) 

and still keep chaining for example...

login
    .dialogForm({ autoOpen: false}) 
    .find("input:submit, button, a")
    .button()


Wasn't that hard:

(function ($) {
    $.fn.dialogForm = function (opts) {
        this.dialog(opts)
            .parent(".ui-dialog")
            .appendTo("form");

        return this;
    };
})($);
0

精彩评论

暂无评论...
验证码 换一张
取 消