rubycentral/cfp-app

View on GitHub
app/assets/javascripts/staff/track.js

Summary

Maintainability
A
0 mins
Test Coverage
$(document).ready(function () {
    if ($('select#track-select').length) {
        filterTableByTrack()
        $(document).on('change', '.track-select', filterTableByTrack)
    }

    function filterTableByTrack() {
        var $dataTable = $('table.datatable').DataTable()
        var track = $('select#track-select option:selected').text()
        if (track === 'All') {
            $dataTable.search('').columns().search('').draw()
        } else {
            $dataTable.search('').columns().search('').draw()
            var $trackColumn = $dataTable.column(':contains(Track)')
            $trackColumn.search(track).draw()
        }
    }
})