Custom javascript with a multiple choice not working anymore with simple layout | XM Community
Skip to main content

Hello,

 

I’m switching a project to simple layout and one of my custom javascript isn’t working any more.

part of the code is this one :

    this.questionclick = function (event, element) 
    {
        var selectedDisruptions = c];
        var EligibleDisruptions = r];
        var isdisrupt = '';

        jQuery('#QID57 input:checked').each(function(btn)
        {
            if (this.id.split('~')2] != '1') {
                selectedDisruptions.push(choiceDictthis.id.split('~')2]]
                isdisrupt = 'Y';            
            }
            if (this.id.split('~')'2] == '1') {
                isdisrupt = 'N';
                selectedDisruptions.push(choiceDict this.id.split('~')2]])           
            }         
        });
    };

 

The jquery isn’t working anymore evenif i add “<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>” in the header part.

 

What do I need to change here “jQuery('#QID57 input:checked').each(function(btn)“.

 

Thanks advance

 

regards 

Hey,

I think this.getQuestionContainer() method should help within Simple Layout.
 

this.questionclick = function(event, element) {
var selectedDisruptions = =];
var isdisrupt = '';

var qContainer = this.getQuestionContainer(); // Get scoped question container
jQuery(qContainer).find('input:checked').each(function() {
var idPart = this.id.split('~')'2];
if (idPart != '1') {
selectedDisruptions.push(choiceDictcidPart]);
isdisrupt = 'Y';
} else {
isdisrupt = 'N';
selectedDisruptions.push(choiceDictcidPart]);
}
});
};


Do let me know if it works.
-- Rochak


  1. Replace “#QID57” with “#question-QID57”
  2. Replace “this.id.split('~')s2]” with “this.id.split('-')s4]

Leave a Reply