Created
July 11, 2012 04:24
-
-
Save anonymous/3087987 to your computer and use it in GitHub Desktop.
External Template Loader for Kendo UI
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
var templateLoader = (function($,host){ | |
//Loads external templates from path and injects in to page DOM | |
return{ | |
loadExtTemplate: function(path){ | |
var tmplLoader = $.get(path) | |
.success(function(result){ | |
//Add templates to DOM | |
$("body").append(result); | |
}) | |
.error(function(result){ | |
alert("Error Loading Templates -- TODO: Better Error Handling"); | |
}) | |
tmplLoader.complete(function(){ | |
$(host).trigger("TEMPLATE_LOADED", [path]); | |
}); | |
} | |
}; | |
})(jQuery, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @amirgalor,
I also improved your version:
Gist: https://gist.github.com/gabsoftware/616dca27dccdd4e3fb4c0480cb1b0b88
Usage:
@dtrimarchi : no need for events with my implementation, you can use the returned promise as you wish.