|
198 | 198 | Griddly.prototype = {
|
199 | 199 | constructor: Griddly,
|
200 | 200 |
|
| 201 | + _isUpdatingFilters: false, |
| 202 | + |
201 | 203 | // create and bind
|
202 | 204 | create: function ()
|
203 | 205 | {
|
|
634 | 636 |
|
635 | 637 | $(".griddly-filters-inline input, .griddly-filters-inline select", this.$element).on("change", $.proxy(function (event)
|
636 | 638 | {
|
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)); |
638 | 647 |
|
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); |
641 | 652 | }, this));
|
642 | 653 |
|
643 | 654 | $(".griddly-filters-inline .filter-content input", this.$element).keyup(function (event)
|
|
895 | 906 |
|
896 | 907 | setFilterValue: function(field, value)
|
897 | 908 | {
|
| 909 | + var input; |
| 910 | + |
898 | 911 | if (typeof (field) === "string")
|
899 |
| - { |
900 |
| - var input = this.getAllFilters().filter(field); |
901 |
| - } |
| 912 | + input = this.getAllFilters().filter(field); |
902 | 913 | else
|
903 |
| - { |
904 |
| - var input = $(field); |
905 |
| - } |
| 914 | + input = $(field); |
906 | 915 |
|
907 | 916 | if (value)
|
908 | 917 | {
|
|
932 | 941 |
|
933 | 942 | setFilterValues: function(filters, isPatch, noRefresh)
|
934 | 943 | {
|
935 |
| - this.options.autoRefreshOnFilter = false; |
| 944 | + this._isUpdatingFilters = true; |
936 | 945 |
|
937 | 946 | var allFilters = this.getAllFilters();
|
938 | 947 |
|
939 | 948 | if (isPatch === true)
|
940 |
| - { |
941 | 949 | allFilters = allFilters.filter(function (i, e) { return typeof (filters[e.name]) !== "undefined"; });
|
942 |
| - } |
943 | 950 |
|
944 | 951 | allFilters.each($.proxy(function (i, e)
|
945 | 952 | {
|
|
948 | 955 |
|
949 | 956 | this.triggerOrQueue(this.$element, "setfilters.griddly", filters);
|
950 | 957 |
|
951 |
| - this.options.autoRefreshOnFilter = true; |
| 958 | + this._isUpdatingFilters = false; |
952 | 959 |
|
953 | 960 | if (!noRefresh)
|
954 |
| - { |
955 | 961 | this.refresh(true);
|
956 |
| - } |
957 | 962 | },
|
958 | 963 |
|
959 | 964 | resetFilterValues: function ()
|
|
0 commit comments