OK.. DUH on my part... it always helps to make sure the capitalization is correct in the template I'm using...
sorry for the noise.............. jonlb On Jun 18, 3:46 pm, Jon Bomgardner <[email protected]> wrote: > I can see that it should work but can anyone see why the code I posted > isn't working? I've been working on this for a while now. I figured > something like this would be easy.... > > jonlb > > On Jun 18, 3:32 pm, Eneko Alonso <[email protected]> wrote: > > > I know getElement works on elements not in the DOM. > > var test = new Element('div', {html: '<a><span>blah</span></a>'}); > > test.getElement('a').set('href', 'x'); > > document.body.grab(test); > > > That should work fine. > > > On Thu, Jun 18, 2009 at 3:16 PM, jonlb <[email protected]> wrote: > > > > Will getElement() only work if the containing element is in the DOM? > > > > For instance, I have this code (in a class): > > > > processTemplate: function(template,classes,container){ > > > var h = new Hash(); > > > var element; > > > if ($defined(container)){ > > > element = container.set('html',template); > > > } else { > > > element = new Element('div',{html: template}); > > > } > > > classes.each(function(klass){ > > > var el = element.getElement('.'+klass); > > > if ($defined(el)){ > > > h.set(klass,el); > > > } > > > },this); > > > return h; > > > } > > > > What this is suppossed to do is to take a passed in template as a > > > string and create a DOM object we can search in. Then it takes the > > > array of CSS class names to search for and tries to find them in the > > > element. If it does, it should add it to the hash which is then passed > > > back to the caller. However, when I run this it is not working. I'm > > > calling it like so: > > > > var template = '<label class="class1"></label><input class="class2">"; > > > var classes = ['class1','class2']; > > > var container = new Element('div'); > > > var els = processTemplate(template, classes, container); > > > > and els is coming back with no elements in it. > > > > Can anyone see where this isn't working? I'm testing this in the > > > Clientcide interactive framework and am verifying all the proper > > > dependencies are loading including Selectors.js. > > > > Any help would be appreciated. > > > > Thanks, > > > jonlb
