この詳細について数時間調査を行っていますが、解決策が見つかりません。
私は不動産のウェブサイトに取り組んでおり、パラメーター (価格、タイプ、寝室など) で物件リストを並べ替えることができる JQuery に基づく機能があります。このような機能を有効にするカスタムの並べ替え関数を作成しました。
コンピューターでは問題なく動作しますが、iOS でテストしたところ、動作しませんでした。
最初は、機能していないのは jQuery だと思っていましたが、いくつかの簡単なテストを実行した後、jQuery のすべてが機能し、解析する必要がある情報を解析していることに気付きました。動作していない部分はソート機能のみです。
そのため、この理由について少し戸惑っています。誰かが役立つかもしれない情報を持っているかどうか知りたいです.
これらはフロントエンドの HTML フォームです。
<div id="filterControls">
<select onclick=”” id="sortOrd">
<option onclick=”” value="asc">ASC ↑</option>
<option onclick=”” value="desc">DESC ↓</option>
</select>
<form id="filter">
<label>Sort items by: </label>
<input type="button" onclick=”” name="sort" value="type" class="first">
<input type="button" onclick=”” name="sort" value="price" class="active">
<input type="button" onclick=”” name="sort" value="bedrooms">
<input type="button" onclick=”” name="sort" value="location" class="last">
</form>
<div class="clear"></div>
</div>
そして、これはjQueryの部分です:
var j$ = jQuery.noConflict();
j$(document).ready(function() {
//alert("I'm alive!");
// CUT THE LENGHT OF THE ADDRESS TEXT
j$('.property_title a').each(function() {
var jthis = j$(this);
jthis.text( jthis.text().slice(0,25) );
jthis.append(" ...");
});
// Custom sorting plugin
// SORT BY PRICE WHEN FIRST LOADING
// accending sort
function asc_sort(a, b){
return (j$(b).find('div[data-type='+ currentSort +']').text()) < (j$(a).find('div[data-type='+ currentSort +']').text());
}
var currentSort = j$('#filter input[class="active"]').val();
//alert(currentSort);
j$("ul#properties li").sort(asc_sort).appendTo('ul#properties');
// USER CAN CHANGE THE SORTING BASE PARAMETER
var ua = navigator.userAgent,
event = (ua.match(/iPad/i)) ? "touchstart" : "click";
j$('#filter input[type="button"]').on("click", function(e){
// == Sorting Types
// accending sort
function asc_sort(a, b){
return (j$(b).find('div[data-type='+ order +']').text()) < (j$(a).find('div[data-type='+ order +']').text());
}
// decending sort
function dec_sort(a, b){
return (j$(b).find('div[data-type='+ order +']').text()) > (j$(a).find('div[data-type='+ order +']').text());
}
// deactivate other buttons
j$('#filter input[type="button"]').removeClass("active");
//activate selected button
j$(this).addClass("active");
//e.preventDefault();
// get info from forms
var sorting = j$('#sortOrd').val();
var order = j$(this).val();
//alert (order);
// define type of sorting to do
if (sorting == 'asc'){
j$("ul#properties li").sort(asc_sort).appendTo('ul#properties');
}
if (sorting == 'desc'){
j$("ul#properties li").sort(dec_sort).appendTo('ul#properties');
}
});
// ASCEND OR DESCEND?
j$('#sortOrd').change(function(event){
//alert("Click event on Select has occurred!");
j$("option:selected", j$(this)).each(function(){
var newSorting = (this).value;
//alert (newSorting);
var currentSort = j$('#filter input[class="active"]').val();
//var newSorting = j$(this).val();
// define type of sorting to do
if (newSorting == 'asc'){
j$("ul#properties li").sort(asc_sort).appendTo('ul#properties');
}
if (newSorting == 'desc'){
j$("ul#properties li").sort(dec_sort).appendTo('ul#properties');
}
// == Sorting Types
// accending sort
function asc_sort(a, b){
return (j$(b).find('div[data-type='+ currentSort +']').text()) < (j$(a).find('div[data-type='+ currentSort +']').text());
}
// decending sort
function dec_sort(a, b){
return (j$(b).find('div[data-type='+ currentSort +']').text()) > (j$(a).find('div[data-type='+ currentSort +']').text());
}
});
});
});
いくつかのテストを行った後、私の最良の仮説は、これが正しく機能していない部分であるということです。これは、iOS でロードするときに自動的にソートされず、他のすべてが正常に機能しているように見えるためです。
// == Sorting Types
// accending sort
function asc_sort(a, b){
return (j$(b).find('div[data-type='+ currentSort +']').text()) < (j$(a).find('div[data-type='+ currentSort +']').text());
}
// decending sort
function dec_sort(a, b){
return (j$(b).find('div[data-type='+ currentSort +']').text()) > (j$(a).find('div[data-type='+ currentSort +']').text());
}
皆さんが私を助けてくれることを願っています。私はあなたの助けに感謝します!