I have link in my page , when user clicks on the link it should give me a dialog box , so to test , i did the following code.
Here is my 'view' code
<div class="panel-body">
<br>
<form class="form-horizontal" role="form" method="POST" action="{{ url('/unsayd') }}">
{{ csrf_field() }}
<div class="form-group">
<div class="col-md-6">
@foreach ($posts as $post)
<article class = "post" data-postid="{{ $post->id }}">
<p>{{$post->userpost}}</p>
<div class='info'>
Posted by {{ $post->user->name }} on {{ $post->user->created_at}}
</div>
<div class = 'interaction'>
<a href=#>Like </a> |
@if(Auth::user() == $post->user)
|
<a href="#" class="edit">Edit</a> |
<a href="{{ route('post.delete', ['post_id' => $post->id]) }}">Delete</a>
@endif
@endforeach
</div>
</div>
<div class="modal fade" tabindex="-1" role="dialog" id="edit-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Edit Post</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="post-body">Edit the Post</label>
<textarea class="form-control" name="post-body" id="post-body" rows="5"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="modal-save">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
When the user clicks the edit link
<a href="#" class="edit">Edit</a>
I want to the js onlick function to be called , Here is the JS code
$('.post').find('.interaction').find('a').eq(2).on('click' , function(){
console.log('It works');
});
When I click the edit button , i dont see anything in the console , but it is supposed to show 'It works'.
This are the scripts included in the main layout
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="{{ URL::to('src/js/app.js') }}"></script>
app.js is stored in public\src\js\app.js
What is the issue here and what is the possible way to fix the issue ? NOTE : when i click edit , i can see the app.js is loading in the cmd after running artisan serve.