Home > Blockchain >  Javascript issues with Rails (caused by preload?)
Javascript issues with Rails (caused by preload?)

Time:12-29

I built a train tracker in Ruby on Rails. I’m running into some javascript issues though.

JS updates the train stops dropdown when a train line is selected. But it doesn’t work when you leave the page and come back, for example, go from this page to Projects via the top menu, then back to the Chicago Train Tracker page via the link. You cannot pick a line anymore.

From what I can tell, it’s because it’s all one "session" and despite leaving the page and coming back, the original JS is still loaded and that… causes it to break somehow? I can’t figure out why but I’m guessing it’s being caused by some rails magic that makes page loading quicker.

Does anyone have any tips on how I can resolve this? For further context, I have the JS right in the .html.erb. file (because I’m still working out how to serve .js files via the Rails assets pipeline

  • Related