I have a simple jquery plugin. It is working fine when i pass a value. But not working when a function returns a value. It's shows the function defenition.
Please try this in Jsfiddle
(function ( $ ) {
$.fn.greenify = function( options ) {
var settings = $.extend({
// These are the defaults.
color: "#556b2f",
backgroundColor: "white",
selectedID:function(){}
}, options );
alert(settings.selectedID);
};
}( jQuery ));
//Plugin Call
$( "div" ).greenify({
color: "orange",
//selectedID:6 it is working fine
selectedID:function (){return 5}
});
selectedIDa function? The name "selectedID" implies that it will be an ID (number or string), not a function, so if you want to use a function when you call.greenify()you'd need to call your function yourself and pass the return. If the.greenify()plugin is expectingselectedIDto be a function then the plugin code would need to treat it as such and call it by adding parentheses (alert(settings.selectedID())).