Last active
October 26, 2015 15:06
-
-
Save royling/91288f360f86aada1f70 to your computer and use it in GitHub Desktop.
Use <link> to define templates and load them ondomready
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var tplts = Object.create(null), importLinks = $('link[rel="import"]'); | |
// load all imported templates | |
importLinks.each(function(idx, elem) { | |
$.get(elem.href, function(data) { | |
var view = elem.getAttribute('href'); | |
tplts[view] = data; | |
if (Object.keys(tplts).length == importLinks.length) { | |
// all are loaded | |
console.info("all templates are loaded:", tplts); | |
} | |
}, 'text'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Define a template like this: