My model returns encoded values from the server. The model contains "enc_res_name" which is HTMLEncoded to display inside an element and "encattr_res_name" which is Attribute Encoded to set as attributes to an element.
The issue I am facing is the HTMLEncoded value displays properly within the element. But the title attribute which is set using "bind-attr" does not rendered properly. The Encoded value is displayed as such in the title.
Template:
<ul>
{{#each item in model}}
<li>
<a {{bind-attr title=item.encattr_res_name}}>
{{{item.enc_res_name}}}
</a>
</li>
{{/each}}
</ul>
Route:
App.IndexRoute = Ember.Route.extend({
model: function() {
return [{'enc_res_name':'<div onmouseover="alert(document.cookie);">haii</div>','encattr_res_name':'<div onmouseover="alert(document.cookie);">haii</div>'}];
}
});
One solution to set the encoded values to title is use triple curly braces and unbound. But there is an option to rename the value where I need to update the title attribute also.
So I am not sure how to set the title attribute to render the encoded values as human readable.
JSBin Link
Aucun commentaire:
Enregistrer un commentaire