You added start
as a function on the prototype, but you are trying to access it from the constructor function, rather than from an instance. To call it via the prototype, you'd have to use the new
keyword to create an instance:
(new ($('form').chardinJs())).start('data-info');
I'm not sure if that would even work. To call it the way you want to, you'd have to make start
a property of chardinJs
:
chardinJs.start = function (txtTag) {
...
But, that woudn't work either, because you'd lose your context.
Really, to accomplish what you are trying to do, you'd have to add those functions to the jQuery object when you call chardinJs
:
$.fn.chardinJs = function () {
// your existing implementation
this.start = chardinJsStart; // reference your start function
return this;
};
Then you could do:
$('form').chardinJs().start('data-info');
One other option would be to keep it the way you have it working already, but pass the method parameter after the method name:
$('form').chardinJs('start', 'data-info');