Skip to content

Instantly share code, notes, and snippets.

@RoelWKramer
Created December 24, 2010 00:49
Show Gist options
  • Save RoelWKramer/753759 to your computer and use it in GitHub Desktop.
Save RoelWKramer/753759 to your computer and use it in GitHub Desktop.
/*
* Roel Kramer - contact@roelkramer.nl
*/
(function($) {
$.fn.append_target_template = function(options) {
var settings = {
'url' : '/default.tpl.html',
'template_id' : 'template'
};
return this.each(function() {
if(options) {
$.extend(settings, options);
}
var target = this;
$.get(settings.url, function(data) {
data = $('<script>').attr('id', settings.template_id)
.attr('type', 'text/x-jquery-tmpl').html(data);
$(target).append(data);
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment