2013-02-07 29 views
6

4つのオプションを含む選択ボックスがあり、それぞれを選択して現在の.item個のdivをすべて削除し、新しい.itemsをロードしてアイソトープを使用して再配置します。アイソトープがAjax読み込みコンテンツで動作しない

$('.menu-select').change(function(){ 
    var selected=$('.menu-select-option:selected').html().toLowerCase(); 
     if(selected=='all') 
      { 
       loadContent('mixed_home_all.html'); 
      } 
     if(selected=='recommended') 
      { 
       loadContent('mixed_home_reco.html'); 
      } 
     if(selected=='popular') 
      { 
       loadContent('mixed_home_pop.html'); 
      } 
}); 

loadContent機能は次のようになります。何らかの理由で

function loadContent(filename){ 
     var $item=$('.item'); 
     $container.isotope('remove', $item); 
     $container.load(filename, function(){ 
      $container.imagesLoaded(function(){ 
       $container.isotope('reLayout'); 
      }); 
     }); 
    } 

reLayoutが機能していません。クラスisotope-itemは個々のアイテムに追加されていません。コンソールログにエラーはありません。

答えて

14

これを解決するには、以前の同位体を破壊し、選択ボックス内のすべての値に対して新しいものをトリガーします。

function loadContent(filename){ 
     var $item=$('.item'); 
     $container.isotope('destroy'); //destroying isotope 
     $container.load(filename, function(){ 
      $container.imagesLoaded(function(){ 
       $container.isotope({ //triggering isotope 
        itemSelector: '.item' 
       }); 
      }); 
     }); 
    } 
+0

こんにちは、私は正常にこのコードを適応し、うまく動作しますが、私のソートは、要素をリロードした後に動作していない...たぶん、あなたは私をHELOすることができます...ありがとう:私のloadContent関数は次のようになります! – vitaminasweb

関連する問題