javascript - Isotope JS Error -


need bit of js error getting please:

uncaught typeerror: $portfolio.isotope not function

   //isotope function - filter portfolio function      $portfolio = $('.portfolio-items');     $portfolio.isotope({         itemselector : 'li',         layoutmode : 'fitrows'     });     $portfolio_selectors = $('.portfolio-filter >li>a');     $portfolio_selectors.on('click', function(){         $portfolio_selectors.removeclass('active');         $(this).addclass('active');         var selector = $(this).attr('data-filter');         $portfolio.isotope({ filter: selector });         return false;     }); 

if don't want script run on pages don't contain required elements (.portfolio-items), can run script conditionally based on length property of element collection stored in $portfolio:

$portfolio = $('.portfolio-items');  if ($portfolio.length) { // if 'length' non zero. enter block...      $portfolio.isotope({         itemselector : 'li',         layoutmode : 'fitrows'     });     $portfolio_selectors = $('.portfolio-filter >li>a');     $portfolio_selectors.on('click', function(){         $portfolio_selectors.removeclass('active');         $(this).addclass('active');         var selector = $(this).attr('data-filter');         $portfolio.isotope({ filter: selector });         return false;     });  } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -