I hvae the following code:
$(".openDialog").live("click", function (e) {
e.preventDefault();
$("<div></div>")
.addClass("dialog")
.attr("id", $(this).attr("data-dialog-id"))
.appendTo("body")
.dialog({
title: $(this).attr("data-dialog-title"),
close: function () { $(this).remove() },
modal: true
})
.load(this.href);
});
$(".close").live("click", function (e) {
e.preventDefault();
$(this).closest(".dialog").dialog("close");
});
Can someone explain how I can decouple the functions form the actions? I am a bit confused with how to do this.
Also what is the purpose of "live" ? I heard before someone suggesting "on". Is "on" better than "live" and how does it actually work?
function callback () {};: now, in the applicable scope,callbackmerely evaluates to said function-object.onis included in the version 1.7+ if you dont have the latest version of jQuery then try using delegate, the purpose is to attach the event handlers to the dynamically added elements to the DOM...