X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2FTemplate.js;h=bbf3ce1f70dc70538f41ce5c43c9f1eb391ca40f;hb=8ded1a9e170e027bb782a8890a9c169ea20950b3;hp=0916bddcccd96d3692ccc7590a83e691eb4f13d4;hpb=718bb748371d65ed36290e0ce10c16b38ea9ff3f;p=roojs1 diff --git a/Roo/Template.js b/Roo/Template.js index 0916bddccc..bbf3ce1f70 100644 --- a/Roo/Template.js +++ b/Roo/Template.js @@ -49,6 +49,10 @@ Roo.Template = function(cfg){ }; 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 +64,12 @@ Roo.Template.prototype = { */ applyTemplate : function(values){ try { - + _t= this; + if (this.url) { + this.afterLoad = function () { _t.applyTemplate(values); }; + this.load(); + return; + } if(this.compiled){ return this.compiled(values); } @@ -100,22 +109,27 @@ Roo.Template.prototype = { loading : false, - load : function (url, success) + afterLoad : false, + + load : function () { + if (this.loading) { return; } + var _t = this; + this.loading = true; this.compiled = false; - var _t = this; + var cx = new Roo.data.Connection(); cx.request({ - url : url, + url : this.url, method : 'GET', success : function (response) { _t.loading = false; _t.html = response.responseText; - success && success(); + _t.afterLoad && _t.afterLoad(); }, failure : function(response) { Roo.log("Template failed to load from " + url);