Since I have 30 questions, it would be quite repetitive to put the script in each question, so I put it in template.js as the first method in the document.ready group:
Code:
// Identify the questions
var thisQuestion = $('[id^=question]');
// Listener on the radios
$('input.radio', thisQuestion).on('click', function(e) {
alert('hi');
$('input[type="radio"]', thisQuestion).prop('disabled', false);
$('input.radio:checked', thisQuestion).each(function(i) {
$(this).closest('tr.answers-list').find('input[type="radio"]').not(this).prop('disabled', true);
});
});
// Initial settings
$('input.radio:checked', thisQuestion).each(function(i) {
$(this).closest('tr.answers-list').find('input[type="radio"]').not(this).prop('disabled', true);
});
Since I don't have access to the {QID}, i changed the var assignment to:
var thisQuestion = $('[id^=question]');
Really appreciate the code tpartner and the hint Joffm. Fantastic support on this forum!
Would it be a better practice to have a custom.js file as part of the manifest and include any custom code like this?