Timeline for <apex:inputText> changes ID and Name
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 9, 2013 at 7:30 | comment | added | eyescream | @MarkPond thx for the tip! I remember playing with it in the past and it was tricky to use so I gave up on $Component. Will retry next time I need JS :) I agree, having the path to be "calculated" server-side will mean less problems like this escaping required by jQuery. | |
Jan 8, 2013 at 18:11 | comment | added | Mark Pond |
@eyescream, the note of $Component needing to sit next to the tag (a sibling) is inaccurate. If the $Component reference is used outside of a VF tag hierarchy it simply must be fully qualified in order to retrieve the element id. Using the 1st example: Best Practices for Accessing Ids script anywhere in the page: <script> var elId = '{!$Component.theForm.thePageBlock.theSection.theSectionItem.yourInputFieldIdHere}'; var $myInput = jQuery("[id='" + elId + "']"); </script> (and is not escaped)
|
|
Jan 8, 2013 at 16:57 | vote | accept | Brian | ||
Jan 8, 2013 at 16:46 | comment | added | eyescream | I don't like $Component, the guy is a bit clunky IMHO. Code that uses it has to sit next to the tag it refers to and I prefer to not sprinkle my JS all over the place but have it in one block on the bottom of the page... But that's a personal pref. really. "Ends-with" might be slow on bigger pages, explicit path will be always fastest but a bit painful if you rearrange the page heavily... Pick your poison ;) | |
Jan 8, 2013 at 16:42 | comment | added | Brian | Thank you for the detailed explanation. Not to go to far off topic ... do find this method better than using {!$Component.formName.theTextInput} or would you see them as equal? Thanks! | |
Jan 8, 2013 at 14:58 | history | answered | eyescream | CC BY-SA 3.0 |