Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

page.js single page application is not working, getting 404 error, I am new to SPA, please help

my index.html looks like these:

<li class="navclass"><a href= "/">Home</a></li>
      <li class="navclass"><a href= "./jobs">Jobs</a></li>
      <li class="navclass"><a href= "./contact">Contact Me</a></li>....

<script src="https://code.jquery.com/jquery-3.2.1.js"
        integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
        crossorigin="anonymous"></script>
  <script src="https://cdn.rawgit.com/visionmedia/page.js/master/page.js"></script>
<script src="controllers/homeView.js"></script>
<script src="controllers/jobsView.js"></script>
<script src="controllers/routes.js"></script>
//my full path for homeView.js and jobsView.js is like these /// //Users/nurbekismailov/Desktop/301/portfolio/public/scripts/controller/homeView.js

//homeView.js  has following

(function(module) {
  const jobsView = {};
  console.log ('we are now in jobsView. yay ')

  jobsView.init = function () {
    console.log ('Inside of jobsView.init()')
    $('#spa').text('this test showing homeView , yay');
  }
  module.jobsView = jobsView;
})(window)

 //jobsView.js  has following

(function(module) {
  const jobsView = {};
  console.log ('we are now in jobsView. yay ')

  jobsView.init = function () {
    console.log ('Inside of jobsView.init()')
    $('#spa').text('this test showing homeView , yay');
  }
  module.jobsView = jobsView;
})(window)

//routes.js has following

page ('/', homeView.init);
page ('/jobs', jobsView.init);
page ();

My Question, where am i missing, i can't find a bug. please help. thanks

1 Answer

//homeView.js has following //jobsView.js has following //routes.js has following

This are three comments of one file, try to put the script using the name of the file.

Like this: <script src="PASTE.FILE.js"><script>