Author: tchemit Date: 2014-04-06 11:06:57 +0200 (Sun, 06 Apr 2014) New Revision: 1842 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1842 Log: fix filter for checkbox inputs + fix statements end (please stop using different code styles at the same time) Modified: trunk/wao-web/src/main/webapp/wao.js Modified: trunk/wao-web/src/main/webapp/wao.js =================================================================== --- trunk/wao-web/src/main/webapp/wao.js 2014-04-06 09:04:23 UTC (rev 1841) +++ trunk/wao-web/src/main/webapp/wao.js 2014-04-06 09:06:57 UTC (rev 1842) @@ -40,11 +40,11 @@ }; -var FilterView = function (sampleRowsFilterModel, $filtersForm) { +var FilterView = function (filterModel, $filtersForm) { var self = this; - this.model = sampleRowsFilterModel; + this.model = filterModel; this.$filtersForm = $filtersForm; this.$selects = $filtersForm.find('select'); this.$inputs = $filtersForm.find('input'); @@ -63,7 +63,12 @@ this.$inputs.each(function (index, input) { var $input = $(input); var parameterName = $input.prop('name'); - var parameterValue = $input.prop('value'); + var parameterValue; + if ($input.attr('type') == 'checkbox') { + parameterValue = $input.prop('checked'); + } else { + parameterValue = $input.prop('value'); + } filter[parameterName] = parameterValue; }); return filter; @@ -103,9 +108,12 @@ var $input = $(input); var parameterName = $input.prop('name'); var parameterValue = filter[parameterName]; - var parameterValue = $input.prop('value', parameterValue); + $input.prop('value', parameterValue); + if ($input.attr('type') == 'checkbox') { + $input.prop('checked', parameterValue); + } }); - } + }; $(this.model).on('updated', function () { self.refreshFilterValues(); @@ -147,7 +155,7 @@ this.view.$inputs.mouseleave(updateFilterValuesIfValueChanged); this.initialFilter = this.view.getFilter(); - } + }; this.reset = function () { this.view.selectOptions(this.initialFilter); @@ -202,11 +210,11 @@ } else { this.$spinner.spin(); } - } + }; this.stopSpinner = function () { this.$spinner.spin(false); - } + }; this.getData = function(path, data) { return path.split('.').reduce(function(prev, prop){ @@ -220,7 +228,7 @@ var result = successCallback.apply(this, arguments); self.stopSpinner(); return result; - } + }; $.get(url, data, stopSpinningAfterCallingSuccessCallback); }
participants (1)
-
tchemit@users.forge.codelutin.com