Sorry about that Kenneth. I'm not sure what happened there.
I've added my changes again, here's a link to the new jsFiddle. Let me know if you still have problems.
/* append script tags for knockout templates, getting the content from a remote url.
id: an id to give the script element. This is used to determine if the template is already included in the page.
url: url to the template html file.
*/
function appendTemplateScript(id, url) {
var dfd = $.Deferred();
if (document.getElementById(id)) {
dfd.resolve();
} else {
$.ajax({
url: url,
dataType: 'html'
}).done(function(data) {
var script = $("<script>").attr("id", id).attr("type", 'text/html').html(data);
$("body").append(script);
dfd.resolve();
});
}
return dfd.promise();
};
// calls appendTemplateScript for several template files and returns a deferred object that is
// resolved when all files have loaded.
function loadTemplates() {
var deferred = new $.Deferred();
$.when(appendTemplateScript('currentTmpl', '/templates/currentTmpl.html'),
appendTemplateScript('01_tmpl', '/templates/01_tmpl.html'),
appendTemplateScript('02_tmpl', '/templates/02_tmpl.html'),
appendTemplateScript('specialism_templ', '/templates/specialism_templ.html'),
appendTemplateScript('disease_templ', '/templates/disease_templ.html'))
.done(function () {
deferred.resolve();
}
);
return deferred.promise();
};
After adding these functions you would just wrap your jquery ready function in a call to the load templates function like so
loadTemplates().done(function () {
$().ready(function () {
// other document ready code omitted.
// Activate Knockout.js
ko.applyBindings(new WizardViewModel());
})
});
Derek