View Full Version : DomHelper

19 Dec 2006, 9:18 AM
After I updated to the new .33 release I've noticed a problem in the DomHelper.

I've got a template like this:

function getTemplateAll(){
var tr = {
tag: 'tr', cls: 'trQueue',
children : [{
tag: 'td', cls: 'imgTD', id: 'test{0}',
children : [{
tag: 'img', id: 'actr{0}', cls: 'clsAction', alt: 'Actions', style: 'cursor: pointer;', src: '/images/icons/iconAction.gif'
tag: 'td', html: '{1}'
tag: 'td', html: '{2}'
tag: 'td', html: '{3}'
tag: 'td', html: '{4}'
var template = YAHOO.ext.DomHelper.createTemplate(tr);
return template;

Now since the release none of the 'ID' properties get filled. Both the (id: 'test{0}') and (id: 'actr{0}') don't get populated.

It works fine in FireFox, but IE7 messes up. Nothing blows up, no ERRORS from the browser at all (until I run my script that looks for certain values), all the ID's are (actr{0})...

Has anyone else experienced this?

19 Dec 2006, 9:37 AM
Well, I fixed it by not doing the template.compile();
Again, if I don't compile it, everything works as it did before.

Hopefully this helps out someone else.

19 Dec 2006, 12:52 PM
I had an epiphany for a more optimized (and much shorter) compile() function. Can you give this a try and let me know your results?

YAHOO.ext.DomHelper.Template.prototype.compile = function(){
var body = ["this.compiled = function(values){ return ['"];
body.push(this.html.replace(this.re, "', values['$1'], '"));
return this;

19 Dec 2006, 12:57 PM
Thank You...that did fix the problem.

No it's time to back and un-comment the .compile() methods..

Thanks again...

19 Dec 2006, 1:02 PM
Sorry about that! I like the new short and simple compile, it should be faster too.

19 Dec 2006, 1:10 PM
No problem....I've been VERY impressed by your library.

I visit your site everyday looking to see if there are updates/changes and I tell everyone who will listen about it. I've got my friends using it and they are all very impressed.

Thanks for the great work.

2 Jan 2007, 6:08 AM

Thanks for that fix. I was running in to problems with ie and the DomHelper this weekend also!