在JS驱动的搜索框上需要一些建议

时间:2018-07-24 15:05:34

标签: javascript jquery

我们移动了JS,现在搜索框提交仅附加到/ URL。它曾经在某一时刻工作,现在我们不确定是什么原因导致页面重新加载而不是提交搜索。

https://ce.harpercollege.edu

if (document.body.contains(document.getElementById("pagePublicHome"))) {
document.getElementById("search-container").style.display = "inline";
(function addSearch() {
    var htm = '<form class="search-form" id="search-form"><label for="quick-search">BECOME MORE</label><span class="search-btn-span" id="search-btn-span"><input id="quick-search" class="form-control" placeholder="Search Course Number, Title, or Keyword..." name="query"><button type="submit" class=""><span class="glyphicon-search glyphicon"></span></button></span></form>';
    document.getElementById("search-container").innerHTML = htm;
})();
$("#search-form").submit(function (e) {
    qry = $(this).find("input")[0].value;
    if (qry !== "") {
        window.location.href = "/search/publicCourseAdvancedSearch.do?method=doPaginatedSearch&showInternal=false&cspIndex=true&isPageDisplayed=true&courseSearch.courseDescriptionKeyword=" + qry;
    } else {
        $(this).find("input")[0].placeholder = "search cannot be blank...";
        $("#search-form").find("input").on("focus", function () {
            $(this).off("focus");
            $("#search-form").find("input")[0].placeholder = "search courses...";
        });
    }
    e.preventDefault();
});
$.each($("div.image>img"), function (i, x) {
    $(this).parent().css({
        "background-image": "url(" + $(this).attr("src") + ")"
    });
    $(this).siblings("div.overlay").css("background-color", "#FFFFFF00");
});

}

0 个答案:

没有答案