(bash|sh|shell|cpp|c|c\+\+|c#|c\-sharp|csharp|css|delphi|pascal|diff|patch|groovy|java|js|jscript|javascript|perl|pl|php||plain|text|py|python|rb|ruby|rails|ror|scala|sql|vb|vbnet|vb\.net|xml|html|xhtml|xslt) Slider partnered with NotApplicable option - strange behaviour when more than one slider - Sawtooth Software Forum

Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Slider partnered with NotApplicable option - strange behaviour when more than one slider

Hi guys

I can't figure out what I'm doing wrong and it's doing my head in.  Have sent in a support request as well but posting here just in case someone has come across this in the past.

I have three slider questions, one after the other on separate pages, with the community NotApplicable thing going on.

Whatever you pick in the first select question follows through to the first slider question.  The first slider question seems to be working fine.  BUT the subsequent slider questions appear to be affected by that select question too which makes no sense.  If the first item in the select question is not picked, the N/A option does not appear from the second slider onward.  If the first code IS picked, the N/A option does come up but the question still doesn't work.  It appears to be having an issue with this piece of code in the javascript validation of the N/A part:

[code}

   // Open end, numeric else if (GLOBAL_SAWTOOTH_[% QuestionName() %].constantSumOrRanking.indexOf(item) == -1) { for (var c = 0; c < cols.length && !err; c++) { err = !$('#' + question + '_r' + item + '_c' + cols[c]).val().length; } }

[/code]

Cannot read property 'length'of undefined

Anyone out there come across this behaviour before?
asked Jul 31, 2018 by Marion Bronze (3,600 points)

1 Answer

0 votes
Upon inspecting your .ssi, it seems all of your Not Applicable questions are using the same list.  Be sure to update each N/A question to use the same list as their related grid question.
answered Jul 31, 2018 by Zachary Platinum Sawtooth Software, Inc. (124,225 points)
Of course!  Why didn't I see that!  Thanks, Zach.
So ... one further thing ... how would I put titles on this?  Say, instead of "Drag your slider to answer" I had something like "Satisfied" aligned left and "not satisfied" aligned right, all in line with the Don't Know?
You want a header row labeling the left end of the slider, the right end of the slider, and the checkboxes?
Yes,  that's right.
First, find and remove this from the sliders question:

    // Hide first row / first column
    if (gridOrientation == 'r') {
        $('#[% QuestionName() %]_div .inner_table > tbody > tr:first-child > td').hide();
    }

    else {
        $('#[% QuestionName() %]_div .inner_table > tbody > tr > td:first-child').hide();
    }


Then add this CSS and JS to the sliders question:

<style>
#[% QuestionName() %]_div .inner_table > tbody > tr:first-child > td:nth-child(2) > div {
    display: inline-block;
    width: 49%;
}

#[% QuestionName() %]_div .inner_table > tbody > tr:first-child > td:nth-child(2) > div:first-child {
    text-align: left;
}

#[% QuestionName() %]_div .inner_table > tbody > tr:first-child > td:nth-child(2) > div:last-child {
    text-align: right;
}
</style>


$(document).ready(function(){
    var td = $('#[% QuestionName() %]_div .inner_table > tbody > tr:first-child > td:nth-child(2)');
    $(td).append($(td).children('div').clone());
    $(td).children(':first-child').text('LEFT LABEL');
    $(td).children(':last-child').text('RIGHT LABEL');
})
You rock, Zach!  Thanks a heap.
...