Call and storing a plugin from a variable or string
I need to store a plugin as a variable or a string to be called later. I feel like I am missing something really simple.
here is a sample test I was trying.
-
$.fn.echo = function (s) {
$(this).each(function () {
$(this).html(s);
});
return this;
};
$.fn.callMethod = function (m, v) {
$(this).each(function () {
$(this).m(v);
});
return this;
};
$(document).ready(function () {
$('body').append($('<div/>').echo('hello'));
$('body').append($('<div/>').callMethod(echo,'calling echo'));
});
I receive the error "echo is not defined". Any Ideas? Is there a built in way to do this?