I'm running datepicker controls on several pages and I want to put as much of the datepicker management in one place/file as I can, so to this end I have created a wrapper for datepicker, that loads the datepicker library and contains several functions that patch datepicker features/functionality to work the way that I need. The wrapper file is loaded in each page using the normal <script src> tag, after the JQuery library is loaded. Inside the wrapper file the datepicker library is loaded using the JQuery getScript mechanism, as follows:
//
// import the "jquery_ui_datepicker_1.12.0.js" script
//
$.getScript( 'jquery_ui_datepicker_1.12.0.js' )
.done( function( script, textStatus ) {
// successful load - run datepicker library initialization code here.
// run date picker patching code here.
} )
.fail( function( jqxhr, settings, exception ) {
alert( 'Triggered ajaxError handler.' );
} );
// define datepicker patching functions starting here.
This allows me to do an include within an include, but in order for the datepicker to work in the same way as if it were loaded using the <script src> tag I need the getScript's call-back feature to call all of the functions and in-line code that would have been normally run using the <script src> tag.
Anyone have an idea how I can do this, short of modifying the content of the datepicker library?
One thought is: Would it be possible to either tell getScript to put the datepicker library it loads into a container that I provide or get the container that it creates? Either way knowing the container, I should be able to wrap the container that the datepicker is in with a function container and call the function. I don't know how to actually do any of this, but the concept doesn't should too difficult.
Looking forward to your ideas and, hopefully, examples.
Thanks,
Howard Brown