jeudi 1 décembre 2016

selecting array data randomly using spacebars

I'm using spacebars to generate a pop quiz-style form. The following code correctly displays the details of the 3rd item in the quiz array


    <form class="testForm">
        <br>
        <br>
        
        <input type="radio" name="multipleChoice" value=><br>
        
        <br>
        <input type="submit" value="Submit"> 
        <br><br><br>
    </form>


and the following helper function correctly generates a random number from the number of items in the quiz array

Template.templateName.helpers({
  randomNumber() {
    return _.random(0, (this.quiz.length - 1));
  }
});

now what I'm trying to do is get the



to use that random number generator to randomly display a quiz. Logically I want to do something like



but that doesn't work obviously




Aucun commentaire:

Enregistrer un commentaire