I have a select, with a long list, in which i can search it, with select2 jquery pluing.
my select:
@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-->
}
I need it to be able to let me search and select the option i want to use. press enter or mouse click. and then it submits the form...
and offcourse it has to work with a normal submit button aswell...
i have tried this code:
$(document).ready(function () {
$('#clientform').on('change', function () {
var $form = $(this).closest('form').on('change', function () {
$form.find('input[type=submit]').click();
});
});
});
in which it submits before i even search, though it works if i just normally scrolls through the list and clicks..