You need to sign in to do that
Don't have an account?
scottnelsonsmith
Component Title escaping HTML characters
In my page I have a component:
<c:AccountFooSection title="DISPLAYING ALL CURRENT FOOS FOR {!titleLink}" />
In my controller, I have this:
private String getTitleLink { return '<br/><a style=\'white-space:nowrap\' href=\'/' + id + '\'>' + name + '</a>'; }
This is what I see for the component's title:
DISPLAYING ALL CURRENT FOOS FOR <br/><a style='white-space:nowrap' href='/001M0000002Kt7jIAC'>Foo Test</a>
I tried placing HTML tags in the title itself, but got the same result. There is no "escape='false'" for components.
Any suggestions? Thanks!
Note: This actually works fine on Winter '10 production, but not in my Spring '11 sandbox. Is Salesforce rendering differently now?
You're correct in that component titles are displayed as escaped, so I had to build a workaround with jQuery.
Since I need to unescape component titles in various pages, I'll create a static resource called unescapeMainTitle_js for reusability.
This grabs the innerHTML of the component title, unescapes it, and puts it back (note: works only when there's just one component per page).
Here's one of my pages:
Works fine, just in time for the Spring '11 push!
All Answers
don't know if this will work, but try replacing the '<' with '<' and '>' with '>'
Thanks for the suggestion, but then it prints out:
DISPLAYING ALL CURRENT FOOS FOR <br/><a style='white-space:nowrap' href='/001M0000002Kt7jIAC'>Foo Test</a>
So it seems to never escape anything.
Dang, sorry. I think you will just have to resign yourself to the fact that you cannot put a link in a title.
You're correct in that component titles are displayed as escaped, so I had to build a workaround with jQuery.
Since I need to unescape component titles in various pages, I'll create a static resource called unescapeMainTitle_js for reusability.
This grabs the innerHTML of the component title, unescapes it, and puts it back (note: works only when there's just one component per page).
Here's one of my pages:
Works fine, just in time for the Spring '11 push!