JavaScript Javascript only loads after refresh (Ruby on rails - Materialize CSS) javascript only loads after refresh

I'm using a Ruby on Rails application in combination with Materialize CSS.

The dropdown of links in the navigation works on the dashboard, but on any other page you have to refresh it first. Same for the Wave effect on buttons and tabs. I already tried 20 or so solutions , but they didn't work.

I also have a javascript for a multistep form that isn't linked to Materialize CSS. It's used in a script tag on the specific page.

 $(document).ready(function () {
    // get all items
    var navListItems = $('div.setup-panel div a'),
        allParts = $('.setup-content'),
        allNextBtn = $('.nextBtn'),
        allPrevBtn = $('.prevBtn');

    allParts.hide();

    navListItems.click(function (e) {
      e.preventDefault();
      var $target = $($(this).attr('href')),
          $item = $(this);
      // hide when disabled
      if (!$item.hasClass('disabled')) {
        navListItems.removeClass('btn-primary').addClass('btn-default');
        $item.addClass('btn-primary');
        allParts.hide();
        $target.show();
        $target.find('input:eq(0)').focus();
      }
    });
    // previous
    allPrevBtn.click(function(){
      var curStep = $(this).closest(".setup-content"),
          curStepBtn = curStep.attr("id"),
          prevStepWizard = $('div.setup-panel div a[target='_blank' href="#' + curStepBtn + '"]').parent().prev().children("a");

      prevStepWizard.removeAttr('disabled').trigger('click');
    });
    //next
    allNextBtn.click(function(){
      //setup next part
      var curStep = $(this).closest(".setup-content"),
          curStepBtn = curStep.attr("id"),
          nextStep = $('div.setup-panel div a[target='_blank' href="#' + curStepBtn + '"]').parent().next().children("a"),
          curInputs = curStep.find("input[type='text']"),
          curRadios = curStep.find("input[type='radio']"),
          curChecks =curStep.find("input[type='checkbox']"),
          isValid = true;

      if (curStep.hasClass('step1')){
        var txt = "";
        if (document.getElementById("snapshot_name").value == null || document.getElementById("snapshot_name").value == "") {
          txt = "You need to fill in a snapshot name";
          document.getElementById("error1").innerHTML = txt;
        }else{
          document.getElementById("error1").innerHTML = txt;
          goToNext(nextStep)
        }
      } else if (curStep.hasClass('step2')){
        var txt2 = "";
        var counter = 0;
        var counterQ1 = 0;
        var counterQ2 = 0;
        for(var i=0; i<curRadios.length; i++){
          if (curRadios[i].checked){
            counter++
          }
        }
        for(var i=0; i<curChecks.length; i++){
          if (curChecks[i].checked){
            var name = curChecks[i].id;
            if (name.search(/Q1/i)){
              counterQ1++
            }else {
              counterQ2 ++
            }

          }
        }

        if (counter == (1) && counterQ1 > 0 && counterQ2 > 0){
          document.getElementById("error2").innerHTML = txt2;
          goToNext(nextStep)
        } else{
          txt2 = "You need to fill in all questions"
          document.getElementById("error2").innerHTML = txt2;
        }
      }
      else if (curStep.hasClass('step3')){
        var txt3 = "";
        var counter = 0;
        var counterQ1 = 0;
        var counterQ2 = 0;
        for(var i=0; i<curRadios.length; i++){
          if (curRadios[i].checked){
            counter++
          }
        }

        if (counter == (5) ){
          document.getElementById("error3").innerHTML = txt3;
          goToNext(nextStep)
        } else{
          txt3 = "You need to fill in all questions"
          document.getElementById("error3").innerHTML = txt3;
        }
      }

      else if (curStep.hasClass('step6')){
        var txt6 = "";
        var counter = 0;
        for(var i=0; i<curRadios.length; i++){
          if (curRadios[i].checked){
            counter++
          }
        }

        if (counter == (14) ){
          document.getElementById("error6").innerHTML = txt6;
          goToNext(nextStep)
        } else{
          txt6 = "You need to fill in all questions"
          document.getElementById("error6").innerHTML = txt6;
        }
      }
      else {
        goToNext(nextStep)
      }

    });

    $('div.setup-panel div a.btn-primary').trigger('click');
  });

  function goToNext(nextStep){
      nextStep.removeAttr('disabled').trigger('click');
      nextStep.removeClass('disabled').trigger('click');
  }

Anyone have an idea what kind of solution I can try?

Answer:1

I would like to pass a variable to a specific page. I found a simple example explaining how to use ajax with wordpress. JavaScript: jQuery(document).ready(function($) { // We'll pass this variable ...

I would like to pass a variable to a specific page. I found a simple example explaining how to use ajax with wordpress. JavaScript: jQuery(document).ready(function($) { // We'll pass this variable ...

  1. wordpress send ajax request
  2. wordpress send ajax response
  3. wordpress send ajax
  4. wordpress ajax send form data
  5. wordpress ajax send email
  6. wordpress ajax send data
  7. wordpress ajax send json
  8. wordpress ajax send array
  9. wordpress ajax send mail
  10. wordpress send ajax form

I was messing around with the first question here: Reduce duplicate characters to a desired minimum and am looking for more elegant answers than what I came up with. It passes the test but curious to ...

I was messing around with the first question here: Reduce duplicate characters to a desired minimum and am looking for more elegant answers than what I came up with. It passes the test but curious to ...

  1. reduce duplicate characters to a desired minimum

In my app (generated with yeoman) i have such structure: view: index.html with ng-view for rendering controller view controller: every controller try to get some data with api urlm like: $scope....

In my app (generated with yeoman) i have such structure: view: index.html with ng-view for rendering controller view controller: every controller try to get some data with api urlm like: $scope....

  1. angularjs load view dynamically
  2. angularjs load view
  3. angularjs load view from controller
  4. angularjs view load before controller
  5. angularjs view loaded event
  6. angularjs load partial view
  7. angularjs load new view
  8. angularjs load different view
  9. angularjs load data before view
  10. angularjs after view load
  11. angularjs load mvc partial view
  12. angularjs ng-view load event
  13. angularjs directive on view load

Is it possible to have multiple clients to the same UDP server ? I'd like to broadcast the same data to all connected clients. Here would be a starting sample, if it helps somehow ... // Server var ...

Is it possible to have multiple clients to the same UDP server ? I'd like to broadcast the same data to all connected clients. Here would be a starting sample, if it helps somehow ... // Server var ...