Things to note:
I don't have access to HTML (rendered by an engine)
jQuery is included in the engine (which is why I don't include it in my code)
This code takes a link and injects it into the html:
$(document).ready(function(){
addSS('https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
addScript('https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
addScript('//InjectedHTML.js');
});
function addScript(str){
var script = document.createElement('script');
script.src = str;
document.head.appendChild(script);
};
function addSS(str){
var link = document.createElement('link');
link.rel= 'stylesheet';
link.href = str;
link.type= 'text/css';
document.head.appendChild(link);
};
InjectedHTML puts datepicker into HTML (in a separate file from the code above):
$(document).ready(function() {
addClass(); //adds class attribute to an input that allows me to use datepicker function
datePicker(); //adds calendar
});
function addClass(){
$("#DateWrapper input").attr("class", "datepicker");
};
function datePicker(){
$( ".datepicker" ).datepicker();
};
Getting this error:
InjectedHTML.js:35 Uncaught TypeError: $(...).datepicker is not a function
Thanks for your help!