Bootstrap下拉菜单-重新加载页面并设置所选值

时间:2018-10-08 13:27:11

标签: javascript html twitter-bootstrap drop-down-menu

我有一个bootstrap下拉菜单,当我从菜单中进行选择时,我想刷新页面并将所选值传递给函数。我设法想到的是能够通过dispatcher事件将下拉菜单中的值传递给函数(在这里称为onclick),但是我不知道该如何伴随/组合请重新加载页面

<div id="navbar" class="navbar-collapse collapse">
    <ul class="nav navbar-nav">
        <li class="dropdown" id="myDropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Select Data <span class="caret"></span></a>
            <ul class="dropdown-menu">
                <li><a href="#" id = "dataset-1" onclick='dispatcher("dataset-1")'>Dataset 1</a></li>
                <li><a href="#" id = "dataset-2" onclick='dispatcher("dataset-2")'>Dataset 2</a></li>
            </ul>
        </li>
    </ul>
</div><!--/.nav-collapse -->

dispacher函数是:

function dispatcher(x){
    console.log('you clicked '+ x)
    useData(x) // <--- some other function that processes data based on x
}

非常感谢!

0 个答案:

没有答案