Reply To: Nested callbacks and test.selected conditions problem

PennController for IBEX Forums Support Nested callbacks and test.selected conditions problem Reply To: Nested callbacks and test.selected conditions problem

#7060
Jeremy
Keymaster

Hi,

How about this?

newTrial("WIPtrial",
    newButton("ContinueYes","[Clicking this should end trial]"),
    newButton("ContinueNo","[Clicking this will lock user out of participating and provide explanation]")
        .callback(
            clear(),
            newText("Explanation goes here").print()
        )
    ,
    newDropDown("DD2Drop","Please select a response")
        .add("Option1","Option2","Option3","Option4","Option5","Option6")
        .callback( getButton("ContinueYes").print() )
    ,
    newText("DD1Text","Yes goes to 2nd DropDown, No will lock the user out of participating (not implemented yet)")
        .print()
    ,
    newDropDown("DD1Drop","Please select a response")
        .add("Yes","No")
        .callback( self.test.selected("Yes")
            .success(
                getButton("ContinueNo").remove(),
                newText("DD2Text","Many choices DropDown").print(),
                getDropDown("DD2Drop").print()
            )
            .failure(
                getButton("ContinueYes").remove(),
                getText("DD2Text").remove(),
                getDropDown("DD2Drop").remove(),
                getButton("ContinueNo").print()
            )
        )
        .print()
        .wait()
    ,
    getButton("ContinueYes").wait() // this can only complete when button is printed
)

Jeremy