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