From 7c1aff78f2ad6593b61c937754377a4028320c94 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 4 Mar 2021 15:47:24 +0800 Subject: [PATCH] add support for onLoad on template --- Roo/Template.js | 9 +++++++++ examples/bootstrap4/popover.html | 2 +- roojs-all.js | 6 +++--- roojs-core-debug.js | 9 +++++++++ roojs-core.js | 6 +++--- roojs-debug.js | 9 +++++++++ 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Roo/Template.js b/Roo/Template.js index 4f8e30281a..8d21e6bd1d 100644 --- a/Roo/Template.js +++ b/Roo/Template.js @@ -53,6 +53,12 @@ Roo.Template = function(cfg){ }; Roo.Template.prototype = { + /** + * @cfg {Function} onLoad Called after the template has been loaded and complied (usually from a remove source) + */ + onLoad : false, + + /** * @cfg {String} url The Url to load the template from. beware if you are loading from a url, the data may not be ready if you use it instantly.. * it should be fixed so that template is observable... @@ -130,6 +136,9 @@ Roo.Template.prototype = { _t.html = response.responseText; _t.url = false; _t.compile(); + if (_t.onLoad) { + _t.onload(); + } }, failure : function(response) { Roo.log("Template failed to load from " + _t.url); diff --git a/examples/bootstrap4/popover.html b/examples/bootstrap4/popover.html index aef7dce9a9..582210d4c0 100644 --- a/examples/bootstrap4/popover.html +++ b/examples/bootstrap4/popover.html @@ -2,7 +2,7 @@ Popover Examples - + diff --git a/roojs-all.js b/roojs-all.js index 6984bdeba5..0fa1253b12 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -213,11 +213,11 @@ return el.nextSibling;}throw 'Illegal insertion point -> "'+M+'"';},insertBefore el.appendChild(N);}else{var O=E(o);N=this.insertHtml("beforeEnd",el,O);}return M?Roo.get(N,true):N;},overwrite:function(el,o,M){el=Roo.getDom(el);if(o.ns){while(el.childNodes.length){el.removeChild(el.firstChild);}F(o,el);}else{el.innerHTML=E(o);}return M?Roo.get(el.firstChild,true):el.firstChild; },createTemplate:function(o){var M=E(o);return new Roo.Template(M);}};}(); // Roo/Template.js -Roo.Template=function(A){if(A instanceof Array){A=A.join("");}else if(arguments.length>1){A=Array.prototype.join.call(arguments,"");}if(typeof(A)=='object'){Roo.apply(this,A)}else{this.html=A;}if(this.url){this.load();}};Roo.Template.prototype={url:false,html:'',applyTemplate:function(A){try{if(this.compiled){return this.compiled(A); +Roo.Template=function(A){if(A instanceof Array){A=A.join("");}else if(arguments.length>1){A=Array.prototype.join.call(arguments,"");}if(typeof(A)=='object'){Roo.apply(this,A)}else{this.html=A;}if(this.url){this.load();}};Roo.Template.prototype={onLoad:false,url:false,html:'',applyTemplate:function(A){try{if(this.compiled){return this.compiled(A); }var B=this.disableFormats!==true;var fm=Roo.util.Format,C=this;var fn=function(m,D,E,F){if(E&&B){if(E.substr(0,5)=="this."){return C.call(E.substr(5),A[D],A);}else{if(F){var re=/^\s*['"](.*)["']\s*$/;F=F.split(',');for(var i=0,G=F.length;i "'+M+'"';},insertBefore el.appendChild(N);}else{var O=E(o);N=this.insertHtml("beforeEnd",el,O);}return M?Roo.get(N,true):N;},overwrite:function(el,o,M){el=Roo.getDom(el);if(o.ns){while(el.childNodes.length){el.removeChild(el.firstChild);}F(o,el);}else{el.innerHTML=E(o);}return M?Roo.get(el.firstChild,true):el.firstChild; },createTemplate:function(o){var M=E(o);return new Roo.Template(M);}};}(); // Roo/Template.js -Roo.Template=function(A){if(A instanceof Array){A=A.join("");}else if(arguments.length>1){A=Array.prototype.join.call(arguments,"");}if(typeof(A)=='object'){Roo.apply(this,A)}else{this.html=A;}if(this.url){this.load();}};Roo.Template.prototype={url:false,html:'',applyTemplate:function(A){try{if(this.compiled){return this.compiled(A); +Roo.Template=function(A){if(A instanceof Array){A=A.join("");}else if(arguments.length>1){A=Array.prototype.join.call(arguments,"");}if(typeof(A)=='object'){Roo.apply(this,A)}else{this.html=A;}if(this.url){this.load();}};Roo.Template.prototype={onLoad:false,url:false,html:'',applyTemplate:function(A){try{if(this.compiled){return this.compiled(A); }var B=this.disableFormats!==true;var fm=Roo.util.Format,C=this;var fn=function(m,D,E,F){if(E&&B){if(E.substr(0,5)=="this."){return C.call(E.substr(5),A[D],A);}else{if(F){var re=/^\s*['"](.*)["']\s*$/;F=F.split(',');for(var i=0,G=F.length;i