The JavaScript code fails to run after implementing highway.js unless the page is manually refreshed

Recently I started using highway.js to implement a fade out/fade in effect while navigating between pages. Despite going through the documentation, I couldn't figure out why my other JavaScript files aren't activating when the new content block loads unless I manually refresh the page. Even after adding a console.log message in one of the scripts, it doesn't fire until I refresh manually. Can anyone suggest what might be causing this issue or how I can trigger the scripts to reload upon transitioning to the new content block? Below is the script responsible for calling highway.js along with some basic scripts linked at the end of my HTML files.

//transition.js
import Highway from '@dogstudio/highway';
import Tween from 'gsap';

class Fade extends Highway.Transition {
    in({ from, to, done }) {
      // Reset Scroll
      window.scrollTo(0, 0);
  
      // Remove Old View
      from.remove();
      done();
  
      // Animation
      Tween.fromTo(to, 0.5,
        { opacity: 0 },
        {
          opacity: 1,
          onComplete: done
        }
      );
    }
  
    out({ from, done }) {
      // Animation
      Tween.fromTo(from, 0.5,
        { opacity: 1 },
        {
          opacity: 0,
          onComplete: done
        }
      );
    }
  }
  
  export default Fade;

//app.js
// Import Highway
import Highway from '@dogstudio/highway';

// Import Transitions
import Fade from './transition.js';

// Call Highway.Core once.
const H = new Highway.Core({
  transitions: {
    default: Fade
  }
});

Answer №1

Recently, I discovered a helpful solution that I wanted to share in case others encounter the same obstacle. I learned that what I needed were 'Renderers,' which can be located in the documentation at highway.js.org. The explanation provided there made it easy for me to implement them effectively. As a result, all of my javascript files are now functioning correctly on their corresponding pages.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Should one be wary of using Javascript setters and getter properties to monitor for modifications?

One interesting feature of Javascript is using Object.create to define setter and getter methods. o = Object.create(Object.prototype, { fooBar: { get: function() { return "Meh" }, set: function(value) { console.log(value) } } }); co ...

Debounce fails to honor the specified timeout period

I'm currently working on implementing a debounce function to handle an HTTP request function. The code is very similar to the example provided below, with only minor changes in function names. To start off, here's the debounce function I am usin ...

How to dynamically adjust the size of Fancybox with ajax

I am having trouble resizing my fancybox when using ajax... Below is the code I am working with: $(".button").click(function() { var formData = $(this).closest('form').serializeArray(); formData.push({ name: this.name, value: this ...

Angular.js: Navigating through HTML content

I am attempting to display a list of HTML data using angular.js and would like to implement ngInfiniteScroll. Here is the template I created: update: <div class="scroll" id="antTalkList" talk-type="total" view-type="total" infinite-scroll=' ...

After reducing the document.domain, the contentWindow of the iframe is met with an Access Denied error

Today, I decided to create an IFRAME dynamically using the following code snippet: var newIframe = document.createElement("iframe"); newIframe.id = 'NewFrame'; newIframe.src = 'NewFrame.html'; document.body.appendChild(newIframe); ...

Tips for navigating between HTML pages using the onclick event in JavaScript

I'm facing an issue with a button that has an onclick event calling the function move(). The objective is to navigate to a different HTML file I created. Despite attempting to use window.location.href, it hasn't been successful. In the source fil ...

Ways to trigger a re-render in useEffect once the data has been updated

My goal is to utilize the useEffect hook to fetch and display the rooms data, and update the rendering when a new room is added to the list. Here is the code snippet that achieves this using useEffect with an empty dependency: const [rooms, setRooms] = use ...

When attempting to compile Angular in production mode, errors may arise such as the Uncaught SyntaxError caused by an Unexpected token '<'

I encountered some errors in the console of my Angular 8 app. When I opened the browser window, it was blank and this error appeared: Uncaught SyntaxError: Unexpected token '<' https://i.sstatic.net/a16DD.png I tried running different ng bui ...

Using JQuery to update dual listboxes in ASP.NET on the client-side, plus a guide on how to fetch the outcomes on the

I've been working on setting up an ASP.NET WebForms page with dual listboxes. This setup includes two side-by-side listboxes, one for available items and the other for selected items, along with buttons to move items between the two. My goal is to ha ...

When I select the radio button, I aim to utilize Ajax to call the SpringMVC controller

If I choose radio button 1 and click submit, my goal is to trigger controller 1, select radio button 2, and then trigger controller 2. Here is the approach I have taken with two controllers: @RequestMapping(value="/ynto10", method=RequestMethod.POST) pub ...

Refresh database using ajax requests

Looking for assistance to update my database with a dropdown menu using ajax. Most examples I've seen involve retrieving data rather than updating it. Can someone please provide guidance? The code in my php updatestatus.php page is as follows: inclu ...

Is it possible to automatically submit a form upon page load?

I've tested a variety of scripts and jquery examples on this site, but none of them seem to fit my specific needs. My goal is to automatically submit a form without the user having to click the submit button. Once the page loads, the autosubmit func ...

Troubleshooting issues with applying a class on load using JavaScript

I am new to Javascript and I am trying to add a class to an element when the page loads. Specifically, I want to change the background color of the element as a test. However, I keep running into the error message "Uncaught TypeError: Cannot read property ...

Guide to adding table classes to AJAX response tables

I am facing an issue with displaying data in a table based on the AJAX request made. The problem arises because the data displayed does not follow the pagination classes applied to the table. My table has pagination functionality where 10 records are shown ...

Jasmine was curious about how to declare a loop of 'its' rather than a loop of 'expects' when testing an Angular factory

In the task of testing an angular factory, here is the code that needs to be tested: var myApp = angular.module('myApp', []); myApp.factory('factoryTest',function(){ return [ {number: 1, name: 'one'}, {nu ...

NodeJS produces identical outcomes for distinct requests

RESOLVED THANKS TO @Patrick Evans I am currently working on a personal web project and could use some assistance. In my website, users are prompted to upload a photo of their face. When the user clicks the "upload" button, the photo is sent with a request ...

Updating Laravel session during Long PollingLet's discuss how to update the Laravel

Currently, I am working with PHP Laravel 4 framework and implementing long polling technique to continuously refresh a list on my HTML page. Additionally, I have an auto-submitting dropdown list on the same page which resets a session value upon user selec ...

Is there a way for me to determine the total number of seconds since the chatbot was first opened?

Here is a snippet of my HTML code: <div class="chatbot chatbot--closed "> <div class="chatbot__header"> <p><strong>Got a question?</strong> <span class="u-text-highlight">Ask Harry</span></p> <s ...

Is there a way to clear the search box in a wenzhixin bootstrap table without refreshing the page when clicked on?

Is there a way to clear the search box in a wenzhixin bootstrap table without refreshing the page when clicking anywhere on the page? <table id="view_table" data-toggle="table" data-search="true" data-page-list="[5, 10, 20]" data- ...

The function to delete in ajax is not functioning properly

My attempt to utilize Ajax for deleting a row from MySQL without refreshing isn't successful as the script doesn't seem to work. // ============ delete.php =========== if(isset($_GET['delete_id'])) { $id = $_GET['delete_id&apo ...