<li class="nav-item mx-2 dropdown" id="bookmarks">
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fas fa-bookmark fa-lg fa-fw"></i>
</a>
<div class="dropdown-menu bookmarks"><a class="dropdown-item" href="http://localhost:8080/articles/foobar/barfoo">
<i class="far fa-file-alt fa-fw fa-lg"></i>
Foobar
</a>
<a class="dropdown-item" href="http://localhost:8080/articles/foobar/barfoo">
<i class="far fa-file-alt fa-fw fa-lg"></i>
Foobar
</a>
<a class="dropdown-item" href="http://localhost:8080/articles/foobar/barfoo">
<i class="far fa-file-alt fa-fw fa-lg"></i>
Barfoo
</a>
</div>
</li>
$('#bookmarks').on('click', function(e) {
console.log('WORKED ONCE?');
$.get('/foo/bar/bookmarks/', function(data) {
$('#bookmarks .bookmarks').html(data);
});
});
@LOOP <a class="dropdown-item" href="{!! url($bookmark->url) !!}">FOOBAR</a> @ENDLOOP
I have this piece of code, a Bootstrap dropdown, that gets populated by clicking on it. However, any other succeeding click events on the #bookmarks
element won't work. I've tried assigning the event like this: $(document).on('click', '#bookmarks', function() ...)
, same thing... it would stop working entirely even. What am I doing wrong? I need it to continuously have that click event to update dropdown list as necessary.
Any thoughts?
NOTE: the @LOOP entity contains the view data AJAX is suppose to receive once it's completed. It's confirmed to be working, but it's only working once.