I have a page where I'm using jquery ui tabs and in each tab I am displaying a table of data that has an onclick javascript function call for each row of data. When I click on a row in the table my javascript function is not working any longer and I am getting the error "TypeError: $.prompt is not a function". This code worked before I put the tabs on the page. Any suggestions?
The event which in the following keydown function code is not returning the correct key codes. I have checked this in Chrome using the developer tools and the console.log(e.which) statement in my code.
var KEY = {
UP: 38,
DOWN: 40,
W: 87,
S: 83
}
// code inside $(function(){} will run after the DOM is loaded and ready
$(function(){
// listen to the key down event
$(document).keydown(function(e){
console.log(e.which);
switch(e.which){
case KEY.UP:
// get the current paddle B's top value in Int type
var top = parseInt($("#paddleB").css("top"));
// move the paddle B up 5 pixels
$("#paddleB").css("top",top-5);
break;
case KEY.DOWN:
var top = parseInt($("#paddleB").css("top"));
// move the paddle B down 5 pixels
$("#paddleB").css("top",top+5);
break;
case KEY.W:
var top = parseInt($("#paddleA").css("top"));
// move the paddle A up 5 pixels
$("#paddleA").css("top",top-5);
break;
case KEY.S:
var top = parseInt($("#paddleA").css("top"));
// move the paddle A drown 5 pixels
$("#paddleA").css("top",top+5);
break;
}
});
});
The up and down arrow keys return the correct codes of 38 and 40, but the w and s keys do not return 87 and 83, they return something different each time. Here is some of the console output.
Here is the output for the w key. The first value is correct, but when I continue to press the key it is different each time.