Camillia
asked on
where is this syntax error coming from?
I have a function like that someone here helped me with. This is the original function
And I replaced it with "on" instead of "live". I get a syntax error at the last line but not sure how to fix it. It looks like the curly brackets and paranthesis all match..so not sure
This is the new one:
$(document).live('pageinit', function () {
$(window).bind('pageshow', function () {
addBodyClass();
});
function getActiveSec(){
return $('section.ui-page-active').attr('id');
}
function addBodyClass(){
$('body').attr('class', getActiveSec());
}
});
And I replaced it with "on" instead of "live". I get a syntax error at the last line but not sure how to fix it. It looks like the curly brackets and paranthesis all match..so not sure
This is the new one:
$(document).on('pageinit',function(){
addBodyClass();
});
function getActiveSec(){
return $('section.ui-page-active').attr('id');
}
function addBodyClass(){
$('body').attr('class', getActiveSec());
}
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ignore my comment it's exactly what leakim has pointed to. I just changed to document ready is the only difference
ASKER
Howcome line 11 was in the orig code (someone else has coded this) but i need to remove it in the new one?? Let me try it and see if it works without it.
ASKER
yeah, that was it. Not sure why the orig had it but the revised one doesnt. It works tho
ASKER
I think it's because i missed one line
$(window).bind('pageshow', function () {
so it should be
$(document).on('pageinit', function() {
$(window).bind('pageshow', function () {
addBodyClass();
});
function getActiveSec(){
return $('section.ui-page-active' ).attr('id ');
}
function addBodyClass(){
$('body').attr('class', getActiveSec());
}
});
$(window).bind('pageshow',
so it should be
$(document).on('pageinit',
$(window).bind('pageshow',
addBodyClass();
});
function getActiveSec(){
return $('section.ui-page-active'
}
function addBodyClass(){
$('body').attr('class', getActiveSec());
}
});
I didn't deserve any points
ASKER
yes, you did. You took the time to contribute.
ASKER