pcbender
10-20-2006, 02:12 PM
The following code works:
var spec = {
tag: 'div',
style: 'width:100%;border:1px solid blue;',
cls: 'wtf',
children: [{
tag: 'a',
href: '{0}',
children: [{
tag: 'span',
html: '{1}'
}]
}]
};
var template = YAHOO.ext.DomHelper.createTemplate(spec);
template.compile();
var el = template.append(divToolbar, ['http://www.google.com', 'boo']);
However, this does not:
var spec = {
tag: 'div',
style: 'width:100%;border:1px solid blue;',
cls: 'wtf',
children: [{
tag: 'a',
href: '{myurl}',
children: [{
tag: 'span',
html: '{mytext}'
}]
}]
};
var template = YAHOO.ext.DomHelper.createTemplate(spec);
template.compile();
var el = template.append(divToolbar,
[
{'myurl' : 'http://www.google.com', 'mytext' : 'boo'}
]
);
The problem is in the generated code:
this.compiled = function(values){ return '<div><span>' + values[mytext] + '</span> (' + values[myurl] + ')</div>';};
As you can see, the myurl reference should be 'myurl'. Same for mytext.
Also not sure if that syntax should work. Shouldn't the gen'd code look something like:
values['children'][0]['myurl']
Anyway.
Thanks.
var spec = {
tag: 'div',
style: 'width:100%;border:1px solid blue;',
cls: 'wtf',
children: [{
tag: 'a',
href: '{0}',
children: [{
tag: 'span',
html: '{1}'
}]
}]
};
var template = YAHOO.ext.DomHelper.createTemplate(spec);
template.compile();
var el = template.append(divToolbar, ['http://www.google.com', 'boo']);
However, this does not:
var spec = {
tag: 'div',
style: 'width:100%;border:1px solid blue;',
cls: 'wtf',
children: [{
tag: 'a',
href: '{myurl}',
children: [{
tag: 'span',
html: '{mytext}'
}]
}]
};
var template = YAHOO.ext.DomHelper.createTemplate(spec);
template.compile();
var el = template.append(divToolbar,
[
{'myurl' : 'http://www.google.com', 'mytext' : 'boo'}
]
);
The problem is in the generated code:
this.compiled = function(values){ return '<div><span>' + values[mytext] + '</span> (' + values[myurl] + ')</div>';};
As you can see, the myurl reference should be 'myurl'. Same for mytext.
Also not sure if that syntax should work. Shouldn't the gen'd code look something like:
values['children'][0]['myurl']
Anyway.
Thanks.