Alan She
unread,Nov 30, 2008, 2:01:35 AM11/30/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to chainjs
I have a problem when using chain.js in my project.
I load some text by ajax request from the server side, which contains
some character like '<', '>'. Obviously it need to escape according to
HTML rules before put into the HTML.
For example, I have this string from server side
'normal <font color="red">NO RED</font> text'
If I just chain it to the html without any special handling, the
result I saw in browser is 'normal NO RED text', while 'NO RED'
colored in red.
However, if I do an escape html handling in chain, the result I saw in
browser is
'normal <font color="red">NO RED</font> text'.
The way I handle html escape is,
$('#something').items(listOfItems).chain({
'.name' : {
content: function(data) {
return escapeHtml(data);
}
}
});
function escapeHtml(str) {
return str
.replace(/"/g,""")
.replace(/</g,"<")
.replace(/>/g,">")
.replace(/&/g,"&");
}
What am I suppose to do to let me see 'normal <font color="red">NO
RED</font> text' in browser?
Thanks for your help!