Make whole cell clickable in single and multi grids

From Catglobe Wiki
Jump to: navigation, search

Challenge

Normally, the grid question require a click on the checkbox or radiobutton. Now, we want it to register the answer when the user click on the cell for the answer option.
Example
Clickable cell.gif

Solution

  • Create a grid question
  • Add the below script to that question

Code

Question.bind('afterShowQuestion', function(ev, question) {
  $(".cg-ui-answer-option").parent().click(function(ev) {
    if($(this).hasClass(".cg-ui-selected")){
      return true;
    }
    else
    {
      $(this).children(".viewer_answer_option_controller").click();
      return false;
    }
  });
});

Source

Questionnaire Resource Id on mmr.catglobe.com site: 339496 (Question: SG2 or MGr1)