From 0324c59100b2cec2e5cd16d26a75b60c161343b3 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville <duncan.sommerville@sourcefabric.org> Date: Sat, 18 Jul 2015 17:28:17 -0400 Subject: [PATCH] Don't reload datatable when selecting same media type --- .../public/js/airtime/library/library-test.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/library-test.js b/airtime_mvc/public/js/airtime/library/library-test.js index ebfc80279..1517c2a5e 100644 --- a/airtime_mvc/public/js/airtime/library/library-test.js +++ b/airtime_mvc/public/js/airtime/library/library-test.js @@ -576,12 +576,12 @@ var AIRTIME = (function(AIRTIME) { var type; aoData.push( { name: "format", value: "json"} ); aoData.push( { name: "advSearch", value: advSearchValid} ); - + // push whether to search files/playlists or all. type = $(".media_type_selector.selected").attr("selection_id"); type = (type === undefined) ? 1 : type; aoData.push( { name: "type", value: type} ); - + $.ajax( { "dataType": 'json', "type": "POST", @@ -968,11 +968,14 @@ $(document).ready(function() { }); $(".media_type_selector").on("click", function() { - $(".media_type_selector").each(function() { - $(this).removeClass("selected"); - }); - $(this).addClass("selected"); - oTable.fnDraw(); + if (!$(this).hasClass("selected")) { + // TODO: deselect any highlighted items when we switch filtering + $(".media_type_selector").each(function () { + $(this).removeClass("selected"); + }); + $(this).addClass("selected"); + oTable.fnDraw(); + } }); });