I would like the ability to add a custom function to an existing jquery class, similar to an extension method in C# (specifically datepicker).
I am able to get a static version of this working by declaring the below:
// declaration
$.ui.datepicker.hello = function () {
alert('heya');
};
// caller
$.ui.datepicker.hello();
However as I am actually concerned with the specific instance of datepicker, I would much rathar be able to declare a function so I could do something like the below:
$("#date").datepicker.hello();
// Or
$("#date").datepicker("hello")
I have tried various methods including using jQuery.fn.extend() and the answers in add custom method to jquery ui dialog, but I get console errors stating "Object doesn't support this action" coming from jquery-ui.min.js when I attempt the accepted solution.
$.widget("ui.datepicker", $.ui.datepicker,{
hello: function () {
alert('yes');
}
});
Is what I am trying to do even possible? Or is it just my execution that is lacking?