From a1ae0bdb838c1907989cf29755d88de1b0434b79 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 11 Mar 2014 15:28:18 +0000 Subject: [PATCH] Add new method etemplate2.getById() to get etemplate object by DOM ID of container node --- etemplate/js/etemplate2.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/etemplate/js/etemplate2.js b/etemplate/js/etemplate2.js index f121050e23..8f3a4ec32a 100644 --- a/etemplate/js/etemplate2.js +++ b/etemplate/js/etemplate2.js @@ -783,6 +783,30 @@ etemplate2.getByApplication = function(app) return list; }; +/** + * Get a etemplate2 object from the given DOM ID + * + * @param {string} id DOM ID of the container node + * @returns {etemplate2|null} + */ +etemplate2.getById = function(id) +{ + for( var name in etemplate2._byTemplate) + { + console.log(name, etemplate2._byTemplate[name]); + for(var i = 0; i < etemplate2._byTemplate[name].length; i++) + { + var et = etemplate2._byTemplate[name][i]; + + if(et.DOMContainer.getAttribute("id") == id) + { + return et; + } + } + } + return null; +} + /** * Plugin for egw.json type "et2_load" *