Monaca Onsen UI Discord Chat Github Repo

Connect JavaScript quiz with Onsen UI



  • I have a JavaScript quiz with radio buttons answers. I have the questions and anwers as an array as you can see.

    The point is that the Onsen UI style is not displaying - the buttons are “plain” buttons instead. I guess I just need to add a really simple codein the answers.push but I can’t figure out.

    Here is the part that I think needs the code:

       answers.push(
              `<label>
                <input type="radio" name="question${questionNumber}" value="${letter}">
                ${letter} :
                ${currentQuestion.answers[letter]}
              </label>`
            );
    

    The array:

    var questionPool = [
        {
          question: "¿Por qué es importante la autoestima?",
          answers: {
            a: "Porque ayuda a moverse en el espacio físico.",
            b: "Porque fomenta la seguridad en uno mismo.",
            c: "Porque se diseña mejor la unidad didáctica."
          },
          correctAnswer: "b"
        },
        {
          question: "Los servicios higiénicos...",
          answers: {
            a: "No se deben separar por sexo.",
            b: "Deben estar limpios y desinfectados.",
            c: "Se diferencian sólo por edad."
          },
          correctAnswer: "b"
        }
    ];
    
    

    Just in case you want to see the complete codepen: https://codepen.io/anon/pen/WMpqKg