title: Dynamically reload Materialize Image Slider photos
body: <p>I'm trying to make my MaterializeCSS image slider dynamically reload photo from different folders as the user switches to another album.
  Here is my approach:</p>
  <pre><code>&lt;script&gt;
      function showPhotos(album) {
          alert(&quot;Show photos function is called&quot;);
          var xmlhttp = new XMLHttpRequest();
          xmlhttp.onreadystatechange = function() {
              if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                  var contents = &quot;&quot;;
                  var count = parseInt(xmlhttp.responseText);
                  for (i = 1; i &lt;= count; i++) {
                      contents += &quot;&lt;li&gt;&quot;;
                      contents += (&quot;&lt;img src=\&quot;images/album_&quot; + album + &quot;/&quot; + (&quot;00&quot; + i).slice(-2) + &quot;.jpg\&quot; /&gt;&quot;);
                      contents += &quot;&lt;/li&gt;\r\n&quot;;
                  }
                  document.getElementById(&quot;photo-slide&quot;).innerHTML = contents;
              }
          }
          xmlhttp.open(&quot;GET&quot;, &quot;/php/gethint.php?q=&quot; + album, false);
          xmlhttp.send();
      }
  &lt;/script&gt;
  </code></pre>
  <p>where the <em><strong>gethint.php?q=</strong></em> basically returns the number of files in a specific folder.</p>
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
          $(&quot;#album1&quot;).click(function(){
              showPhotos(1);
              $('.slider').slider({full_width: true, height: 600});
          });
          $(&quot;#album2&quot;).click(function(){
              showPhotos(2);
              $('.slider').slider({full_width: true, height: 600});
          });
          $(&quot;#album3&quot;).click(function(){
              showPhotos(3);
              $('.slider').slider({full_width: true, height: 600});
          });
      });
  &lt;/script&gt;
  </code></pre>
  <p>where album1, album2 and album3 are the 3 items in my drop-down list.</p>
  <p>The result works fine with the first album selection. Everything works as expected. But when I tried to switch album, the new pictures are loaded too, transitions are fine, but the indicator at the bottom starts acting weird. I need either a fix for my approach, or a better solution for what I need.</p>