Created
January 31, 2014 05:03
-
-
Save srkama/8726849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This sinnpets tell how to pass external functions to another function