I have a field, date input field(Js calendar, datepicker field) already loaded, once I select “post date” the field becomes visible (style display:block;), also it is loading(adds to document header, appends) javascript files like jquery-1.8.3.min.js, bootstrap.min.js, bootstrap-datetimepicker.js. I don’t know when to load this:
///////////////////////////////////// how it is appended once “post date” clicked, it’s done 3 times for every .js file/////////////////
var script = document.createElement(‘script’);
script.src = “jquery/jquery-1.8.3.min.js”;
script.onload = function () {
//do stuff with the script
};
document.head.appendChild(script);
How to load everything so that it is actually working and JavaScript is activated on the datepicker field. How to load everything and so activate the date field, whats the right order, I am confused a bit. I can probably use some sort timeout function to load first js file, after some time the other one, but it does not sound that good idea.
Anyways I get deferred is not a function error and getScript shows other errors, something doesn’t load correctly. so I worked around a new solution like this:
This shouldn’t give any errors and function should be set once all other files are loaded. I have no idea if this really is ideal solution, but I think so?