Skip to content

Instantly share code, notes, and snippets.

@srkama
Created January 31, 2014 05:03
Show Gist options
  • Save srkama/8726849 to your computer and use it in GitHub Desktop.
Save srkama/8726849 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="hello">hello</div>
</body>
</html>
$.testfunc = function (elem, options) {
base = $(this);
base.elem = elem;
base.options = options;
base.init = function() {
console.log('called from test func');
if(base.options) {
if (base.options.init) {
for(var func in base.options.init) {
console.log(base.options.init[func]());
}
}
}
};
base.init();
};
function hello1() {
console.log("called from hello");
}
options={init:[hello1]};
$.testfunc($("#hello"),options);
@srkama
Copy link
Author

srkama commented Jan 31, 2014

This sinnpets tell how to pass external functions to another function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment