如何将数据排序重置为原始排序

时间:2014-06-25 15:38:15

标签: javascript jquery sorting plugins

我正在使用DataFilters jQuery插件的现有网站上工作,其中数据按最低价格和最高价格排序。由于我无法控制的原因,我无法编辑原始代码,并且在单击时需要添加链接,它会在排序之前将排序重置为其原始状态。

感谢您的帮助

更新:我可以访问类似于此处的DataFilter初始化代码:http://www.datafilters.info/config.php

更新:我可以访问我可以更新的DataFilter初始化代码

$(document).ready(function() {
    $("#filterControls").show();
    initFilters();
});

function initFilters() {

    function freeTextSearchExtractText(element) {
        return element.find('.brand').text() + " " + element.find('.model').text() + " " + element.find('.stock').text() + " " + element.find('.os').text();
    }

    var sortBy = [
        {"heading": "Price (low-high)", "id": "cost", "direction": "1"},
        {"heading": "Price (high-low)", "id": "cost", "direction": "-1"},
        {"heading": "Brand (A-Z)", "id": "brand", "direction": "1"},
        {"heading": "Brand (Z-A)", "id": "brand", "direction": "-1"}
    ]

    $('#handsetList').DataFilter('init', {
        "filters": [
            {"id":"cost", "dataType":"currency", "filterType":"sortOnly"},

            {"heading": "Brand", "id": "brand", "dataType": "default", "filterType": "checkboxes" },
            {"heading": "4G readiness",   "id": "tariffType", "dataType": "default",  "filterType": "checkboxes", "hideSingleItem": "true" },
            {"heading": "Refurbished", "id": "model", "dataType": "default", "filterType": "checkboxes", "items": ["~Refurb"] },
            {"heading": "Stock status", "id": "stock", "dataType": "stock", "filterType": "checkboxes" },

            {"heading": "Operating system", "id": "os", "dataType": "default", "filterType": "checkboxes"}
        ],

        "pageSize": 9,
        "useFreeTextSearch": true,
        "freeTextSearchHeading": "Search phones",
        "freeTextSearchExtractTextFn": freeTextSearchExtractText,
        "sortingDropDown": sortBy,
        "sortingDropDownHeading": "Sort phones",
        "onSuccess": onSuccessFnDesktop,
        "useLoadingOverlayOnFilterIfSlow": true,
        "slowTimeMs": 300,
        "hashNavigationEnabled": true
    });

    var checkVisible = setInterval(function() {
        if($('.filterWrapper').length == 0 || !$('.filterWrapper').is(':visible')) return;
        clearInterval(checkVisible);
        merchandisedFilters();
    }, 300);
}

0 个答案:

没有答案