I'm trying to show a modal window by giving enter on a textbox
, I had the following code to do it but it does not work for me:
$("#txt_codigoCat").on("keydown", function (event) {
if (event.which == 13) {
$('#popupBusquedaCliente').modal('show');
}
});
I add the code I use for the modal window:
<!-- Modal Escenario-->
<div class="modal fade" id="popupBusquedaCliente" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Cerrar</span></button>
<h4 class="modal-title" id="myModalLabel">Busqueda de Familia</h4>
</div>
<div id="BusquedaCliente" class="modal-body">
<form role="form">
<div class="form-group">
<label for="stock_bodega">Busqueda por:</label>
<select class="form-control" style="width: 40%" id="stock_bodega">
<option>Código</option>
<option>Nombre</option>
<option>Estado</option>
</select>
<label for="texto_buscar">Texto a Buscar:</label>
<input type="text" class="form-control" id="texto_buscar" autocomplete="off" style="text-transform: uppercase">
</div>
<div style="position: relative; overflow: auto; width: 100%; height: 200px;" class="dataTables_scrollBody">
<table style="width: 100%;" id="busqueda_cliente" class="display nowrap dataTable no-footer" cellspacing="0" width="100">
<thead>
<tr>
<th>Codigo</th>
<th>Nombre</th>
<th>Estado</th>
<th>Categoria</th>
<th>CatNombre</th>
</tr>
</thead>
</table>
</div>
</form>
</div>
@* Load datatable css *@
<link href="//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" rel="stylesheet" /> @* Load datatable js *@ @section Scripts{
<script src="//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('#busqueda_cliente').DataTable({
"bSort": false,
"ajax": {
"url": '@Url.Action("Todos", "venmanfamilia")',
"type": "GET",
"datatype": "json"
},
"columns": [{
"data": "Codigo"
}, {
"data": "Nombre"
}, {
"data": "Estado"
}, {
"data": "Categoria"
}, {
"data": "CatNombre"
}],
filter: false,
"paging": false,
"ordering": false,
"info": false,
language: {
paginate: {
first: "Primero",
previous: "Anterior",
next: "Siguiente",
last: "Ultimo"
}
}
});
});
</script>
}
<div class="modal-footer">
<button type="button" class="btn btn-primary">Seleccionar</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
<!-- Modal Escenario-->