My view is like this :
...
<td @click="modalShow('modal-option', '{{ $i }}')">
...
</td>
...
@section('modal')
<option-modal id="modal-option" :id="idModal"></option-modal>
@endsection
When the view clicked, it will display modal like this :
<template>
<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
...
<div class="modal-body">
<a href="javascript:" class="text-danger" :id="'image-delete-' + id">
<span class="fa fa-trash"></span>
</a>
</div>
...
</div>
</div>
</div>
</template>
<script>
export default{
name: 'OptionModal',
props:['id'],
}
</script>
I display modal with vue.js 2
When I click icon trash, I want to call javascript
I have global javascript. The name is main.js
The main.js is like this :
for(let i = 0; i < 5; i++) {
$('#image-delete-'+i).click(function(){
$('input[name="image-'+i+'"]').val('');
document.getElementById("image-view-"+i).style.display = "none";
document.getElementById("image-upload-"+i).style.display = "";
$('.modal').modal('hide');
});
}
When I clicked the trash icon in modal, javascript was unsuccessful called
How can I solve this problem?
@click? you get there full access to your methods and data.