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