Skip to content

Commit 5d63ba1

Browse files
committed
Handle case of filterlist with no items
1 parent 898113f commit 5d63ba1

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

Griddly/Scripts/griddly.js

+22-14
Original file line numberDiff line numberDiff line change
@@ -776,31 +776,39 @@
776776
var self = this;
777777

778778
var checkbox = $(el).parents(".filter-content").find("input:first");
779-
var filter = checkbox.data("griddly-filter");
780779

781-
var selector = ".dropdown-menu li" + (!filter.data("griddly-filter-ismultiple") ? ":not(.griddly-list-group-header)" : "");
782-
783-
$(el).click(function ()
780+
if (checkbox.length)
784781
{
785-
$(this).parents(".filter-content").find(selector).addClass("griddly-filter-selected");
786-
$(this).parents(".filter-content").find("input").prop("checked", true).first().change();
787-
});
782+
var filter = checkbox.data("griddly-filter");
783+
784+
var selector = ".dropdown-menu li" + (!filter.data("griddly-filter-ismultiple") ? ":not(.griddly-list-group-header)" : "");
785+
786+
$(el).click(function ()
787+
{
788+
$(this).parents(".filter-content").find(selector).addClass("griddly-filter-selected");
789+
$(this).parents(".filter-content").find("input").prop("checked", true).first().change();
790+
});
791+
}
788792
}, this));
789793

790794
$(".griddly-filters-inline .filter-content .griddly-clear", this.$element).each($.proxy(function (i, el)
791795
{
792796
var self = this;
793797

794798
var checkbox = $(el).parents(".filter-content").find("input:first");
795-
var filter = checkbox.data("griddly-filter");
796799

797-
var selector = ".dropdown-menu li" + (!filter.data("griddly-filter-ismultiple") ? ":not(.griddly-list-group-header)" : "");
798-
799-
$(el).click(function ()
800+
if (checkbox.length)
800801
{
801-
$(this).parents(".filter-content").find(selector).removeClass("griddly-filter-selected");
802-
$(this).parents(".filter-content").find("input").prop("checked", false).first().change();
803-
});
802+
var filter = checkbox.data("griddly-filter");
803+
804+
var selector = ".dropdown-menu li" + (!filter.data("griddly-filter-ismultiple") ? ":not(.griddly-list-group-header)" : "");
805+
806+
$(el).click(function ()
807+
{
808+
$(this).parents(".filter-content").find(selector).removeClass("griddly-filter-selected");
809+
$(this).parents(".filter-content").find("input").prop("checked", false).first().change();
810+
});
811+
}
804812
}, this));
805813
},
806814

Griddly/Views/Shared/Griddly/GriddlyFilterInline.cshtml

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
}
4242
else
4343
{
44-
<a class="btn btn-link btn-xs filter-trigger">
44+
<a class="btn btn-xs @(filterList == null || filterList.Items.Count > 0 ? "btn-link filter-trigger" : "disabled")">
4545
<span class="griddly-filter-display">
4646
@if (filterBox != null)
4747
{
@@ -105,7 +105,10 @@
105105
}
106106
}
107107
</span>
108+
@if (filterList == null || filterList.Items.Count > 0)
109+
{
108110
<span class="caret"></span>
111+
}
109112
</a>
110113
<div class="filter-content">
111114
@if (filterBox != null)

0 commit comments

Comments
 (0)