ajax - Issue with $(document).ready -
i'v got 2 questions. first. how can reduce code?
$('#m').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/main.php').fadein('normal'); return false; }); $('#b').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/blog.php').fadein('normal'); return false; }); $('#p').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/portfolio.php').fadein('normal'); return false; }); $('#l').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/lebenslauf.php').fadein('normal'); return false; }); $('#k').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/kontakt.php').fadein('normal'); return false; });
i'm using lib called perfect scrollbar. included way:
$(document).ready(function(a){a("#scrollbox").perfectscrollbar({wheelspeed:20,wheelpropagation:!1})});
when main.php loaded in script, scrollbar not there should be. it's because document doesn't refresh usual. need write working when loaded in?
write function & pass each selector & filepath function
$('#m').click(some_function() { helperfunction($(this), 'inc/main.php'); }); function helperfunction(selector, phpfilepath) { var href = selector.attr('href'); $('#con').hide().load(phpfilepath).fadein('normal'); return false; }
Comments
Post a Comment