This might be a bit to read, but I think it would be fairly confusing without some context. Right now, I have a site that has angular keeping the same header on all my pages, simply including an ng-view to load a specific page's content. My index.html file looks something like this
<!DOCTYPE html>
<html lang="en">
<!-- MY HEADER -->
<div class="ng-view"></div>
<!-- MY FOOTER -->
<!-- Angular scripts -->
<script src="js/angular/angular.min.js"></script>
<script src="js/angular-route/angular-route.min.js"></script>
<!-- Angular app script -->
<script src="js/app.js"></script>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- MY JAVASCRIPT-->
<script src="js/filter.js"></script>
</html>
In one of my views, I am trying to set up a table filter (filtering a list of tournaments based on year). The view file is named archives.html, and currently looks like:
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-body">
<div align="center">
<div class="btn-group">
<button type="button" class="btn btn-filter" data-target="2016">2016</button>
<button type="button" class="btn btn-filter" data-target="2015">2015</button>
<button type="button" class="btn btn-filter" data-target="2014">2014</button>
</div>
</div>
<br>
<div class="table-responsive">
<table class="table table-filter table-hover">
<thead class="thead-inverse">
<tr>
<th>Tournament</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<tr data-status="2016">
<td>Capilano Junior</td>
<td><a href="http://bcgazone4.bluegolf.com/bluegolf/bcgazonefour16/event/bcgazonefour165/leaderboard.htm">Results</a></td>
</tr>
<tr data-status="2015">
<td>Point Grey Junior</td>
<td><a href="http://bcgazone4.bluegolf.com/bluegolf/bcgazonefour16/event/bcgazonefour1611/leaderboard.htm">Results</a></td>
</tr>
<tr data-status="2014">
<td>Shaughnessy Junior</td>
<td><a href="http://bcgazone4.bluegolf.com/bluegolf/bcgazonefour14/event/bcgazonefour144/leaderboard.htm">Results</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
And finally, the javascript code, in js/filter.js:
$(document).ready(function () {
$('.btn-filter').on('click', function () {
var $target = $(this).data('target');
if ($target != 'all') {
$('tbody tr').css('display', 'none');
$('tbody tr[data-status="' + $target + '"]').fadeIn('slow');
} else {
$('tbody tr').css('display', 'none').fadeIn('slow');
}
});
});
I am assuming that angular loads all of the scripts I included in my index.html file for each individual view, such that in filter.js, the table in my archives.html view will be successfully located. However, nothing is happening with the filter. Am I wrong in this assumption, or am I being careless with other parts of the javascript?