1
我有一个选择,有一个长列表,我可以在其中搜索它,用select2 jQuery插件。当选择选项时,jquery提交选择表格
我的选择:
@using (Html.BeginForm("ProjectList", "Client", FormMethod.Get, new { id = "clientform", name = "clientoverviewform"}))
{
<div class="form-group">
<label for="sel1">Select Client</label>
@if (Model.ClientList != null)
{
<select class="form-control selectpicker" data-live-search="true" id="sel1" name="id">
@foreach (var client in Model.ClientList)
{
<option value="@client.Id">@client.Name</option>
}
</select>
}
</div><!-- end form-group-->
<div class="form-group">
<input type="submit" value="Vis" class="form-control">
</div><!-- end form-group-->
}
我需要它能够让我搜索和选择我想使用的选项。按回车或鼠标点击。然后提交表单...
和offcourse它与正常工作的提交按钮藏汉...
我曾经尝试这样的代码:
$(document).ready(function() {
$('#clientform').on('change', function() {
var $form = $(this).closest('form').on('change', function() {
$form.find('input[type=submit]').click();
});
});
});
在它之前提交我甚至搜索,但它的工作原理,如果我只是正常滚动列表并点击..
目前尚不清楚你的问题究竟是什么,或者你实际存在什么问题。请提供一个[mcve]来演示这个问题(不需要我们需要你的服务器端代码) – Jamiec