-1
Gentlemen, because in the code below is not passing the data (fetch) to the modal so I can update?
Html
<a href="#editModal" class="edit" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Editar"></i></a><input type="hidden" name="update_id" id="update_id">
<div class="form-group">
<label>Título</label>
<input type="text" class="form-control" name="title" id="title" placeholder="Nome do lead" required>
</div>
<div class="form-group">
<label>Telefone</label>
<input type="text" class="form-control" name="phone" id="phone" required>
</div>
<div class="form-group">
<label>E-mail</label>
<input type="email" class="form-control" name="email" id="email" required>
</div>
<div class="form-group">
<label>Valor</label>
<input type="text" class="form-control" name="value" id="value" required>
</div>
</div>
Jquery
// Edit modal
$(document).ready(function() {
$(document).on('click', 'edit', function(){
$('#editModal').modal('show');
$tr = $(this).closest('tr');
var data = $tr.children("td").map(function(){
return $(this).text();
}).get();
console.log(data);
$('#update_id').val(data[0]);
$('#title').val(data[1]);
$('#phone').val(data[2]);
$('#email').val(data[3]);
$('#value').val(data[4]);
$('#step').val(data[5]);
$('#prob').val(data[6]);
});
});
.on('click', 'edit', ...
shouldn’t be.on('click', '.edit', ...
, with the point beforeedit
signaling that it is a CSS class?– Woss
@Woss, not my friend.
– Renan Bessa
It should. The second argument there is the selector. It may be that not only is that the problem, but that this is wrong is.
– Woss