0
jquery script works if put out of foreach, but qd put in it does not work and shows no error in console:
<div class="box-indicated">
@foreach($list_indicated as $indicated)
<label class="checkbox-inline pull-right">
<input type="checkbox" {{ $indicated['is_active'] == '1' ? "checked" : null }} data-toggle="toggle" name="deactivate{{$indicated['id']}}" id="deactivate{{$indicated['id']}}" data-width="75" data-height="25" data-offstyle="danger" data-on="Ativo" data-off="Inativo" class="email_repass_created">
</label>>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
jQuery('#deactivate{{$indicated['id']}}').change(function(){
swal({
title: 'Aviso',
html: "Dados atualizados com sucesso",
confirmButtonText: 'OK',
confirmButtonColor: '#55a07f',
allowOutsideClick: false,
type: 'success'
})
console.log('deactivate');
})
</script>
@endforeach
Guy doesn’t make sense you have a function for each item, imagine that this loop will have 100 records, 100 repeated functions to do the same thing.
– Kayo Bruno
0
votar contra
favorita
o script do jquery funciona se colocar fora do foreach, mas qd coloco dentro ele não funciona e não mostra nenhum erro no console:
it has no change in the element and so does not run the console and everything that is within that function ... and also could be done differently created a function and just call there with a line (although it seems kind of strange what you want to do), could explain what you really want to do, maybe there are different paths to your problem– novic