Skip to content

Commit cb0aa08

Browse files
committed
Consistently fire filterchange
1 parent 4dfecfe commit cb0aa08

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

Build/CommonAssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("1.5.22")]
19-
[assembly: AssemblyFileVersion("1.5.22")]
18+
[assembly: AssemblyVersion("1.5.23")]
19+
[assembly: AssemblyFileVersion("1.5.23")]
2020
//[assembly: AssemblyInformationalVersion("1.4.5-editlyalpha2")]

Griddly/Scripts/griddly.js

+20-15
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@
198198
Griddly.prototype = {
199199
constructor: Griddly,
200200

201+
_isUpdatingFilters: false,
202+
201203
// create and bind
202204
create: function ()
203205
{
@@ -634,10 +636,19 @@
634636

635637
$(".griddly-filters-inline input, .griddly-filters-inline select", this.$element).on("change", $.proxy(function (event)
636638
{
637-
this.triggerOrQueue(this.$element, "filterchange.griddly", this.$element, event.target);
639+
if (!this._isUpdatingFilters)
640+
{
641+
this.triggerOrQueue(this.$element, "filterchange.griddly", this.$element, event.target);
642+
643+
if (this.options.autoRefreshOnFilter)
644+
this.refresh(true);
645+
}
646+
}, this));
638647

639-
if (this.options.autoRefreshOnFilter)
640-
this.refresh(true);
648+
$(this.$element).on("change", ".griddly-filters-form input, .griddly-filters-form select", $.proxy(function (event)
649+
{
650+
if (!this._isUpdatingFilters)
651+
this.triggerOrQueue(this.$element, "filterchange.griddly", this.$element, event.target);
641652
}, this));
642653

643654
$(".griddly-filters-inline .filter-content input", this.$element).keyup(function (event)
@@ -895,14 +906,12 @@
895906

896907
setFilterValue: function(field, value)
897908
{
909+
var input;
910+
898911
if (typeof (field) === "string")
899-
{
900-
var input = this.getAllFilters().filter(field);
901-
}
912+
input = this.getAllFilters().filter(field);
902913
else
903-
{
904-
var input = $(field);
905-
}
914+
input = $(field);
906915

907916
if (value)
908917
{
@@ -932,14 +941,12 @@
932941

933942
setFilterValues: function(filters, isPatch, noRefresh)
934943
{
935-
this.options.autoRefreshOnFilter = false;
944+
this._isUpdatingFilters = true;
936945

937946
var allFilters = this.getAllFilters();
938947

939948
if (isPatch === true)
940-
{
941949
allFilters = allFilters.filter(function (i, e) { return typeof (filters[e.name]) !== "undefined"; });
942-
}
943950

944951
allFilters.each($.proxy(function (i, e)
945952
{
@@ -948,12 +955,10 @@
948955

949956
this.triggerOrQueue(this.$element, "setfilters.griddly", filters);
950957

951-
this.options.autoRefreshOnFilter = true;
958+
this._isUpdatingFilters = false;
952959

953960
if (!noRefresh)
954-
{
955961
this.refresh(true);
956-
}
957962
},
958963

959964
resetFilterValues: function ()

0 commit comments

Comments
 (0)