我正在尝试整合同位素,但是我在使用ajax时遇到了问题.
这是代码:
<script type="text/javascript"> var currentPage = 1; $(function(){ var getUrl = 'loadMovies.PHP'; var getQuery = 'genrefilter='+movieSelection.elements["genreFilter"].value; getQuery += '&yearfilter='+movieSelection.elements["yearFilter"].value; getQuery += '&titlesort='+movieSelection.elements["titleSort"].value; getQuery += '&ratingsort='+movieSelection.elements["ratingSort"].value; getQuery += '&yearsort='+movieSelection.elements["yearSort"].value; getQuery += '&runtimesort='+movieSelection.elements["runtimeSort"].value; getQuery += '¤tPage='+currentPage; var $container = $('#movieBox'); //$container.isotope({itemSelector: '.movie'}); $.ajaxSetup({cache:false}); var ajax_load = "<img class='loading' src='images/load.gif' alt='loading...' />"; //$("#genreFilter").change(function(){$container.isotope('insert',ajax_load).load(getUrl,getQuery);}); $("#genreFilter").change(function(){$('#movieBox').html(ajax_load).load(getUrl,getQuery);}); });
HTML只是“”
随着同位素线的评论,我实际上得到了按预期显示的div,但由于我无法弄清楚如何在同位素线上工作,我无法让它工作.
我试图将同位素与“插入”方法结合起来,我在没有ajax的情况下开始工作.
摘自:http://isotope.metafizzy.co/docs/adding-items.html
“插入方法
更有可能的是,您希望使用insert方法,该方法执行addItems未命中的所有操作. insert会将内容附加到容器,过滤新内容,对所有内容进行排序,然后触发reLayout,以便正确布置所有项目元素.
var $newItems = $('<div class="item" /><div class="item" /><div class="item" />'); $('#container').isotope( 'insert',$newItems );
最后一行是我需要与ajax线集成,但我只是没有看到我可以放置它.我尝试了几种方法,其中一种方法显示在注释掉的行中.
有谁能看到这个问题?
得到这样的工作:
原文链接:https://www.f2er.com/ajax/160228.html$(function(){ var $container = $('#movieBox'); $container.isotope({ itemSelector: '.movie' }); $.ajaxSetup({cache:false}); var ajax_load = "<img class='loading' src='images/load.gif' alt='loading...' />"; $('#genreFilter').change(function(){ $('#genreFilter').change(function(){ var getQuery = 'loadMovies.PHP?'; getQuery += 'genrefilter='+movieSelection.elements["genreFilter"].value; getQuery += '&yearfilter='+movieSelection.elements["yearFilter"].value; getQuery += '&titlesort='+movieSelection.elements["titleSort"].value; getQuery += '&ratingsort='+movieSelection.elements["ratingSort"].value; getQuery += '&yearsort='+movieSelection.elements["yearSort"].value; getQuery += '&runtimesort='+movieSelection.elements["runtimeSort"].value; getQuery += '¤tPage='+currentPage; return $.ajax({ cache:false,url: getQuery,success: function(data){$container.isotope('insert',data)} }); }); });