Saturday, September 17, 2011

Define callback functions

It's a example show how to define callback function; for example, open, close.



Define callback functions



<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.16/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.16/themes/smoothness/jquery-ui.css">
<title>jQuery UI Dialog</title>
</head>
<body>
i can code! for Web.
<div id="myDialog">
Test Dialog of jQuery UI
</div>
<script>
(function($){

var functionOK = function(){
alert("OK");
},
functionCancel = function(){
alert("Cancel");
},
Options = {

open: function() {
alert("callback function - open");
},

close: function() {
alert("callback function - close");
},

title: "<a href='http://icancode-4-web.blogspot.com/'>i can code! for Web.</a>",
buttons:{
"OK": functionOK,
"Cancel": functionCancel
}
};

$("#myDialog").dialog(Options);
})(jQuery);
</script>
</body>
</html>

No comments:

Post a Comment