Reputation: 41
I am not able to recieve any calls to my js file. What could be the problem? Using MVC
view, file.hbs
<div class="container">
<h2 onClick="test()">Title</h2>
{{>list}}
</div>
<script src='/public/js/game.js' type='text/javascript'></script>
public game.js file
function test(){
alert("alert");
}
router file
'use strict';
const express = require('express');
const router = express.Router();
const GameController = require('../controllers/game');
router.get('/', GameController.initialize);
module.exports = router;
Upvotes: 0
Views: 24
Reputation: 26
A function cannot be called unless it was defined in the same file or one loaded before the attempt to call it. Means, you need to move the script-tag before the div-tag and it should work. The console should also give you some hints.
Upvotes: 1