自己写插件小知识

2010-08-18 16:55:31 by 【6yang】, 131 visits, 收藏 | 返回

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FOO API</title>
</head>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
(function($){
 $.foo = {
  alertBox: function(msg){
   this.dialog.alert({
    id  : "request-connect",
    title : "How you're connected?"
   }).open();
  },
  dialog: {
   alert: function(setting){
    return this._alert._create(setting);
   },
   _alert: {
    options: {
     id  : "request-connect",
     title : "How you're connected?"
    },
    _create: function(setting){
     var self = this;
     self.options = setting;
     return self;
    },
    open: function(){
     var self = this;
     //alert(self.options.id);
     //alert(self.options.title);
     return self;
    }
   }
  }
 }  
})(jQuery);

jQuery(function($){    
 var dialogBox = $.foo.alertBox({
   id     : "request-connect",
   title  : "How you’re connected?"
  });
 //dialogBox.open();
 
 var settings = { validate: 2, limit: 5, name: "foo" };
 var options = { validate: 1, name: "bar" };
 jQuery.extend(true, settings, options);
 alert(settings.validate);
})
</script>
<body>
</body>
</html>

分享到:
share

    图片原图

    loading

    loading