mmenu搜索字段:搜索表单和位置

Mar*_*arc 5 jquery mmenu

我正在为我的网站使用mmenu jquery插件。现在,我注意到可以将最新版本的搜索字段配置为搜索表单。

1.我怎么意识到的?

我的普通搜索表单如下所示:

<form action="search.html" method="post">
    <input type="text" name="item" id="searchform" placeholder="Search" />
    <button type="submit" name="submit" id="searchbutton">Search</button>
    <input type="hidden" name="do" value="search" />
    <input type="hidden" name="searchin" value="all" />
    <input type="hidden" name="send" value="1" />
</form>
Run Code Online (Sandbox Code Playgroud)

我已经尝试过了,但是它不起作用:

$("#menu").mmenu({
    navbars: { content: [ "prev", "searchfield", "close" ] },
    searchfield: {
        search: false,
    form: {
        action: "search.html",
        method: "post" },
    input: {
        type: "text",
        name: "item",
        id: "searchform" },
    input: {
        type: "hidden",
        name: "do",
        value: "search" },
    input: {
        type: "hidden",
        name: "searchin",
        value: "all" },
    input: {
        type: "hidden",
        name: "send",
        value: "1" }
    }
});
Run Code Online (Sandbox Code Playgroud)

2.是否可以将搜索字段下移到菜单末尾?

谢谢!

小智 2

我知道这是一个旧线程,但万一有人也在寻找答案

  1. 为了在搜索字段中使用自定义表单,您需要添加配置,而不是选项。所以,正确的格式是:

    $("#menu").mmenu({
        navbars: { content: [ "prev", "searchfield", "close" ] },
        searchfield: {
            search: false
        }
    },{
        "searchfield": {
            form: {
                action: "search.html",
                method: "post" 
            },
            input: {
                type: "text",
                name: "item",
                id: "searchform" 
            }
        }
    });
    
    Run Code Online (Sandbox Code Playgroud)
  2. 您可以更改导航栏位置:

    "navbars": [ { "position": "bottom", "content": [ "searchfield" ] } ]