2
我想要Metafizzy的同位素插件工作。这是我的设置,除了我从SQL数据库拉容器项目 - http://jsfiddle.net/trewknowledge/jJZEN/jquery同位素过滤与数据库
任何人都可以帮我找出为什么它不工作?
这是我使用
的JavaScript
//Load all items straight away
$(document).ready(function(){
showEntries('*');
});
//Isotope filter
function filterEntries() {
var $container = $('#entries');
$select = $('#filters select');
$container.isotope({
itemSelector: '.item'
});
$select.change(function() {
var filters = $(this).val();
$('.active').removeClass('active');
if (filters != '.item') {
$(filters).addClass('active');
}
$container.isotope({
filter: filters
});
});
};
//Pull in data from database
function showEntries(str) {
if (str=="") {
document.getElementById("entries").innerHTML="";
return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("entries").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","<?php bloginfo('template_url'); ?>/getentries.php?q="+str,true);
xmlhttp.send();
//Fire filter function
filterEntries();
}
</script>
HTML
<section id="filters">
<select name="entries" onchange="showEntries(this.value)">
<option value="*">show all</option>
<option value=".item323" >323</option>
<option value=".item266" >266</option>
<option value=".item277" >277</option>
<option value=".item289" >289</option>
</select>
</section> <!-- #filters -->
<div id="entries" class="clearfix">
</div><!--entries-->
PHP
0码
它是什么,是不是工作?你有一个在线沙箱或jsfiddle,哪里可以体验到什么不工作?帮助我们来帮助你... – Systembolaget 2012-08-07 06:37:18
jsfiddle中的一个没有连接到sql数据库。它过滤的项目在html中是硬编码不动态的。我只是将它展示为我想达到的一个例子。我想了解如何在20分钟前做到这一点,并很快发布我的答案 – Allan 2012-08-07 07:20:37
干杯,这很好;其他人可能会遇到你的情况发生故障。 – Systembolaget 2012-08-07 07:24:08