i have following lines included at the bottom of my index.php:
<script type="text/javascript" language="javascript" src="class/jquery-1.4.3.min.js"> </script>
<script type="text/javascript" language="javascript" src="class/jquery.nivo.slider.pack.js"></script>
<script type='text/javascript' language='javascript'>
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
problem lies in $(window).load
...
index.php's body is updated onload through ajax call which delivers div#slider upon matching. this makes it nivoSlider()
not executing. do you have any trick to make this thing work. i do prefer non-jquery way around it, but at the end of the day anything helps.
many thanks
WEBPAGE IS HERE
i have following lines included at the bottom of my index.php:
<script type="text/javascript" language="javascript" src="class/jquery-1.4.3.min.js"> </script>
<script type="text/javascript" language="javascript" src="class/jquery.nivo.slider.pack.js"></script>
<script type='text/javascript' language='javascript'>
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
problem lies in $(window).load
...
index.php's body is updated onload through ajax call which delivers div#slider upon matching. this makes it nivoSlider()
not executing. do you have any trick to make this thing work. i do prefer non-jquery way around it, but at the end of the day anything helps.
many thanks
WEBPAGE IS HERE
Share Improve this question edited Apr 29, 2016 at 15:39 bozzmob 12.6k17 gold badges51 silver badges73 bronze badges asked Mar 21, 2011 at 12:08 daniel.tosabadaniel.tosaba 2,5639 gold badges36 silver badges47 bronze badges 1- This question stems from an earlier post stackoverflow./questions/5370247/… in which I identified the source of the problem, which allowed Daniel to pose the question and get a detailed answer. – Marc Audet Commented Mar 21, 2011 at 13:08
2 Answers
Reset to default 5Add the call in the callback for the AJAX load.
$('.something').load( 'http://www.example./foo', function() {
$(this).find('#slider').nivoSlider();
});
Example using your code (for body):
$(function() { // run on document ready, not window load
$('#content').load( 'page.php?c=2&limit=5', function() {
$(this).find('#slider').nivoSlider();
});
});
For link:
<!-- updates links like so -->
<a class='nav' href='page.php?category=art&limit=5&c=1'>art</a>
// in the same document ready function
$('a.nav').click( function() {
var $link = $(this);
$('#content').load( $link.attr('href'), function() {
$(this).find('#slider').nivoSlider();
$link.addClass('selected'); // instead of setting bg directly to #828282;
});
return false; // to prevent normal link behavior
});
Would you not want to use $(document) rather than $(window)?
$(window).load(function() { $('#slider').nivoSlider(); });
or shorthand
$(function() { $('#slider').nivoSlider(); });
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745159551a4614326.html
评论列表(0条)