jquery - Reinitialise scripts after ajax-load -
jquery - Reinitialise scripts after ajax-load -
i have 2 scripts trying initialise each time new posts loaded using ajax-load plugin wordpress. question initialise script , how?
here's load more function comes plugin...
/* * ajaxloadmore * main function responsible returning 1 true ajaxloadmore instance functions everywhere. * * @since 2.0.0 */ function ajaxloadmore(){ global $ajax_load_more; if( !isset($ajax_load_more) ) { $ajax_load_more = new ajaxloadmore(); } homecoming $ajax_load_more; } // initialize ajaxloadmore(); // think need initialise scripts endif; // class_exists check
the 2 scripts trying initialise flexslider , custom funcitona post filter.
the flexslider positioned @ footer of page..
<script src="<?php bloginfo('template_directory'); ?>/plugins/flexslider/jquery.flexslider.js"></script> <script type="text/javascript" charset="utf-8"> $(window).load(function() { $('.flexslider').flexslider(); }); </script>
the filter function beingness called after body tag...
function stringcontainsanyitems(stringval, items) { (var = 0; < items.length; i++) { console.log("item: " + items[i]); if (stringval.indexof(items[i]) > -1) { homecoming true; } } homecoming false; } //$.when().then(function( ajaxloadmore ) { $(function initializefilter() { //initialize first item $('div.portfolio-item:visible:first').addclass("first-item"); var $checkboxes = $("input[id^='type-']"); $('input[type=checkbox]:checked').attr('checked', false); $checkboxes.change(function () { //remove special classes first item , item $('div.portfolio-item').removeclass("one-item"); $('div.portfolio-item').removeclass("first-item"); $('div.portfolio-item').removeclass("last-item"); if ($('input[type=checkbox]:checked').length > 0) { var selectorarray = []; $checkboxes.filter(':checked').each(function () { selectorarray.push($(this).attr('rel')); console.log($(this).attr('rel')); }); $('[data-category]').hide() // hide rows .filter(function () { homecoming stringcontainsanyitems($(this).data('category'), selectorarray); }).show(); // cut down set matched , show } else { $('[data-category]').show(); } var visiblecount = $('div.portfolio-item:visible').length; if (visiblecount === 1) { // stuff here, time special class 'one-itemä added // maybe can handle ::after here $('div.portfolio-item:visible').addclass("one-item"); } else { $('div.portfolio-item:visible:first').addclass("first-item"); $('div.portfolio-item:visible:last').addclass("last-item"); } }); });
jquery wordpress initialization infinite-scroll
Comments
Post a Comment