Reputation: 58375
I am wanting to add a refresh
function to a jQuery plugin so that I can do
$(selector).tooltipster("refresh")
I've been trying to use this https://stackoverflow.com/a/4414356/123415 but without success. This is what I'm trying:
(function($) {
$.extend(true, $[ "fn" ][ "tooltipster" ].prototype, {
refresh: function() {
this._update(this.Content);
},
});
})(jQuery);
For reference, the plugin's code declares _update
inside of
(function ($, window, document) {
Plugin.prototype = {
_update: function() {
/* update code */
}
}
})( jQuery, window, document );
I'm trying to extend tooltipster I think I've included all the necessary code above though.
The problem seems to be that the Plugin's methods are all within Plugin.prototype which I can't seem to access. As it stands, I'm just getting "Cannot set property 'refresh' of undefined" in the console.
Update If I run $.fn.tooltipster.prototype
in the console, I get
- $.fn.(anonymous function) {refresh: function}
+ constructor: function () {
+ refresh: function () {
+ __proto__: Object
Implying that I have added refresh somewhere on tooltipster but not where it's meant to be.
Upvotes: 0
Views: 70
Reputation: 4505
Can you not just set it straight on the prototype?
$.someplugin.someMethod = function(){}
Upvotes: 0