vendredi 20 décembre 2019

Checkbox remembered only on page refresh

I have a page with checkboxes. If I check some of them and go back, when I return to that page with a link the checkboxes are unchecked, if at that point I refresh the page, the checkboxes I previusly checked becomes cheked again. I have no javascript to manage this behavior, just Turbolinks enabled. Why is this and how can I restore checkboxes right from the start?

<!doctype html>
<html lang="en">

<head>
  <link rel='icon' href='favicon.ico' type='image/x-icon' />

  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="style/css/bootstrap.min.css">
  <link rel="stylesheet" href="style/css/style.css" type="text/css">

  <script src="https://kit.fontawesome.com/e5f3028323.js" crossorigin="anonymous"></script>

  <!-- JavaScript -->
  <script type="text/javascript" src="/js/turbolinks.js"></script>

  <script type="text/javascript" src="/js/js.cookie.js"></script>

  <title>App</title>
</head>

<body>

  <section id="setup-game" class="container">
    <div class="row">
      <div class="col text-center">
        <div class="list-checkbox list-group list-button mx-auto mt-2">
          <label class="list-group-item d-flex justify-content-between align-items-center pointer-cursor">
            <input class="checkbox-cw" type="checkbox">
          </label>
          <label class="list-group-item d-flex justify-content-between align-items-center pointer-cursor">
            <input class="checkbox-cw" type="checkbox">
          </label>
          <label class="list-group-item d-flex justify-content-between align-items-center pointer-cursor">
            <input class="checkbox-cw" type="checkbox">
          </label>
          <label class="list-group-item d-flex justify-content-between align-items-center pointer-cursor">
            <input class="checkbox-cw" type="checkbox">
          </label>
          <label class="list-group-item d-flex justify-content-between align-items-center pointer-cursor">
            <input class="checkbox-cw" type="checkbox">
          </label>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col text-center mb-3">
        <button type="button" class="btn-largo" onclick="keepTrack();">Track Game</button>
      </div>
    </div>
  </section>

  <!-- JavaScript -->
  <script type="text/javascript" src="js/bootstrap-native-v4.min.js"></script>
  <script type="text/javascript" src="js/script.js"></script>
</body>

</html>



Aucun commentaire:

Enregistrer un commentaire