javascriptjquerypikaday

Get jquery plugin instance in a different js file?


I am using the plugin PikaDay:

https://github.com/dbushell/Pikaday

On my page, this plugin is being applied to one of my form elements as follows:

$('#datepicker').pikaday(config);

For one reason or another, I do not have the ability to edit the JS file that this code is being executed from. I can however, add my own new JS files.

I would like to access the pikaday instance created in the original JS file, in my new JS file?

Is such a thing possible?


Solution

  • Yes it is. If you read the full documentation. They have mentioned it.

    Something like this.

     var picker = new Pikaday({ field: $('#datepicker')[0] });
    

    You can refer picker now .