开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜