X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2FTemplate.js;h=121b46250882170a302555527274cb1adf904cb3;hb=6ad3cd3a05c8dd0b133db2e9149bb86801b9ef78;hp=8e28fd80b940a2d934222006f917f02988c676ac;hpb=7fc2a1506ab155fb198b0920ef893fa7eca3c629;p=roojs1 diff --git a/Roo/Template.js b/Roo/Template.js index 8e28fd80b9..121b462508 100644 --- a/Roo/Template.js +++ b/Roo/Template.js @@ -44,11 +44,17 @@ Roo.Template = function(cfg){ // bc this.html = cfg; } - + if (this.url) { + this.load(); + } }; Roo.Template.prototype = { + /** + * @cfg {String} url The Url to load the template from. + */ + url : false, /** * @cfg {String} html The HTML fragment or an array of fragments to join("") or multiple arguments to join("") */ @@ -60,7 +66,8 @@ Roo.Template.prototype = { */ applyTemplate : function(values){ try { - + _t= this; + if(this.compiled){ return this.compiled(values); } @@ -100,17 +107,32 @@ Roo.Template.prototype = { loading : false, - load : function (url, success) + afterLoad : false, + + load : function () { + if (this.loading) { - return false; + return; } - var cx = new Roo.data.Connection({ - url : url, + var _t = this; + + this.loading = true; + this.compiled = false; + + var cx = new Roo.data.Connection(); + cx.request({ + url : this.url, method : 'GET', - success : success, - failure : function() { - Roo.log("Template failed to load from " + url); + success : function (response) { + _t.loading = false; + _t.html = response.responseText; + _t.url = false; + _t.afterLoad && _t.afterLoad(); + }, + failure : function(response) { + Roo.log("Template failed to load from " + url); + _t.loading = false; } }); },