I can't seem to attach an event to my struts radio button.
It's defined as:
<s:radio id="useCourseList"
name="useCourseList"
required="true"
label="Course List?"
labelposition="top"
list="#{'1':'No','2':'Yes'}"
value="1"
/>
But I can't seem to create a click event for it. I tried
$('#useCourseList').click(function(event){
if($(this).val() === '2') {
renderCourseList();
} else {
switchToSingleCourseMode();
}
});
But that attaches to "useCourseList" - the actual ids of the buttons, though, are "useCousreList1" and "useCourseList2".
It seems wonky to assign the same click event to both of them, especially since when more options are added later, I'll have to add to those too. How can I add "one and done"?
I'm assuming that the rendered html is not going to have the id exactly as it is defined. You can try:
$('[id*="useCourseList"]').click(...