Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.66 KB | None | 0 0
  1. (function(jq) {
  2.  
  3.     var methods = {
  4.  
  5.    
  6.         init: function(options) {
  7.             var settings = {
  8.                     something: 'value'
  9.             }
  10.             return this.each(function() {
  11.                                 jq.extend(settings,options);
  12.                 //do something for each match
  13.             });
  14.         },
  15.  
  16.         changestate: function() {
  17.             alert(settings.someSetting); //settings not in scope, id want it to somehow be
  18.                 }
  19.     }
  20.  
  21.     jq.fn.myplugin = function(method) {
  22.         if (methods[method]) {
  23.             return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
  24.         } else if (typeof method === 'object' || !method) {
  25.             return methods.init.apply(this, arguments);
  26.         }
  27.     };
  28.  
  29. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement