Reputation: 1301
I have this and it works fine:
$(document).ready(
highlightTableRow
);
but when I add a second function (see below) the second doesn't work.
$(document).ready(
highlightTableRow,
attachClickLinkHandlerForRowLink
);
What's the correnct syntax for adding a second function to my ready function? Thanks.
edit: add syntax errors. (eclipse)
$(document).ready(
highlightTableRow(); **// error:Syntax error, insert ")" to complete Arguments**
attachClickHandlerForRowLink(); **//error: Missing semicolon**
); **// error: Syntax error on token ")", delete this token**
var originalRowBackground;
function highlightTableRow(){
$('[class^="contentRow"]:has(a)').live('mouseenter', enterRowFunction).live('mouseleave', exitRowFunction);
}
function enterRowFunction(){
originalRowBackground = $(this).css('background-color');
$(this).css({'background-color': "#EFE3FF", 'cursor': 'pointer'});
}
function exitRowFunction(){
$(this).css({'background-color': originalRowBackground, 'cursor': 'pointer'});
}
function attachClickHandlerForRowLink(){
$('[class^="contentRow"]:has(a)').live('click', clickRowLink);
}
function clickRowLink(){
window.location = $(this).find("a").attr("href");
} **//error: Missing semicolon**
Upvotes: 2
Views: 193
Reputation: 10305
you could do
$(document).ready(function() {
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
also you could change the $(document).ready()
part into $(function()
so you would get
$(function() {
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
does the same only shorter
Upvotes: 9
Reputation: 1009
Why don't you use like this?
$(document).ready(function(){
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
Upvotes: 3
Reputation: 83358
document.ready
takes a function
$(document).ready(function() {
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
Upvotes: 2
Reputation: 206068
try like:
$(document).ready(function(){
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
Upvotes: 4
Reputation: 63956
I would do something like this:
$(document).ready(function()
{
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
Am I missing the point?
Upvotes: 3