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;
};
})($);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.