javascript - slick slider will not instantiate when content is loaded via ajax -


what trying load in portfolio item on click of div pertains portfolio item. load portfolio single page , populate view. slick slider not being instantiated , not work when loaded via ajax.

this code instantiates slick slider (usually wrapped in $(document).ready. if enter in console after ajax gets loaded works, if add end of .click() function (which load content via ajax) seems not intantiated - , nothing in console tell me why not:

$('.slick-slider').slick({  		lazyload: 'ondemand',  		centermode: true,  		centerpadding: '60px',  		variablewidth: true,  		speed: 300,  		slidestoshow: 1,  		adaptiveheight: true,  		responsive: [  		    {  		      breakpoint: 1024,  		      settings: {  		        slidestoshow: 3,  		        slidestoscroll: 3,  		        infinite: true,  		        dots: true  		      }  		    },  		    {  		      breakpoint: 600,  		      settings: {  		        slidestoshow: 2,  		        slidestoscroll: 2  		      }  		    },  		    {  		      breakpoint: 480,  		      settings: {  		        slidestoshow: 1,  		        slidestoscroll: 1  		      }  		    }  		    // can unslick @ given breakpoint adding:  		    // settings: "unslick"  		    // instead of settings object  		]  	  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

then here code click of

$(document).ready(function() {  	$('#gallery-view > div').click(function() {  		  		var toload = $(this).attr('id')+' #portfolio-single';  	    $('#ajax-view').hide('fast',loadcontent);  	    $('#load').remove();  	    $('#ajax-wrapper').append('<span id="load">loading...</span>');  	    $('#load').fadein('normal');  	  	    //window.location.hash = $(this).attr('id').substr(0,$(this).attr('href'));  	    function loadcontent() {  	        $('#ajax-view').delay(1000).load(toload,'',shownewcontent());  	    }  	     	    function shownewcontent() {  		    	        $('#ajax-view').show('normal',hideloader());	           	    }  	    function hideloader() {  	        $('#load').delay(1000).fadeout('normal');  	    }    	});  	  	    });

the link trying accomplish can found at:

http://april.philiparudy.com/gallery/

if click on div circle image see loading without slick slider.

i have single slick slider working here: http://april.philiparudy.com/portfolio/abby-warner/

is there type of callback function running instantiate slick slider after ajax loaded?

your code it's ok. problem assigning click #gallery-view > div.

you must existing element, not element have added after function click.so try change , parent or show me ajax call see adding new item.

also change click onclick , functions should not inside $(document).ready

take below.

$(document).ready(function() {     $('#gallery-view > div').on('click', function() {         var toload = $(this).attr('id')+' #portfolio-single';         $('#ajax-view').hide('fast',loadcontent);         $('#load').remove();         $('#ajax-wrapper').append('<span id="load">loading...</span>');         $('#load').fadein('normal');     });   });      function loadcontent() {         $('#ajax-view').delay(1000).load(toload,'',shownewcontent());     }      function shownewcontent() {                     $('#ajax-view').show('normal',hideloader());                  }     function hideloader() {         $('#load').delay(1000).fadeout('normal');     } 

hope it's helps!


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -