This is my table:
<div class="col-md-13">
<table data-url="data1.json" data-height="500" data-sort-name="name" data-sort-order="desc" class="table table-striped table-bordered">
<thead>
<tr>
<th data-field="id" data-align="center" data-sortable="true">Nível Acesso</th>
<th data-field="name" data-align="center" data-sortable="true">Nome</th>
<th data-field="price" data-align="center" data-sortable="true">Usuário</th>
</tr>
</thead>
<tbody id="nmUsuario"></tbody>
</table>
</div>
I can not get the doubleclick event and pass the selected line as a parameter to the controller via jquery. This is my jquery skeleton.
function ConsultarAcesso() {
str = "";
$.ajax({
url: '/CadastroAcesso/ConsultaAcesso',
datatype: 'json',
contentType: 'application/json;charset=utf-8',
type: 'POST',
data: JSON.stringify({ }),
success: function (data) {
},
error: function (error) {
}
})
}
I turned this into fiddle and it worked.
<div id="divDb" class="teste" style="background-color: green; color: white; font-size: 30px;">
Duplo clique aqui e vai funcionar!
</div>
$(document).ready(function () {
$(".teste").dblclick(function () {
alert("Alô Paulão, Funcionou!");
});
});
I did this in my project and nothing.
function AtualizaTabela() {
str = "";
$.ajax({
url: '/CadastroAcesso/AtualizaTabelaUsuario',
datatype: 'json',
contentType: 'application/json;charset=utf-8',
type: 'POST',
data: JSON.stringify({}),
success: function (data) {
$(data.result_usu).each(function () {
str += '<tr>';
str += '<td data-field="id" class="col-md-4 clique">' + this.Nivel_Acesso1 + '</td>';
str += '<td data-field="name" class="col-md-4 clique">' + this.NM_Usuario + '</td>';
str += '<td data-field="price" class="col-md-4 clique">' + this.Usuario1 + '</td>';
str += '</tr>';
})
$('#nmUsuario').html(str);
str = "";
},
error: function (error) {
}
})
}
$(document).ready(function () {
AtualizaTabela();
$(".clique").dblclick(function () {
alert("Alô Paulão, Funcionou!");
});
})
See that I created a class called clique
for every <TD>
of my table.