Created
March 7, 2018 20:26
-
-
Save eatoncw/279579ca5ec76b07b9e89d4221b5139c to your computer and use it in GitHub Desktop.
dynamically generate params for GET request to update products page based on user-selected filters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//uses jquery to send request to rails 5 built api-only backend | |
$('.sales-filters input').on('click', function() { | |
var params = {}; | |
var filters = $('.sales-filters input:checked'); //get array of all checked radio buttons | |
for (i = 0; i < filters.length; i++) { | |
params[filters[i].name] = filters[i].value //dynamically create params for GET request based on name and value attributes | |
} | |
var url = window.location.origin + '.....' | |
fetchAndPaginate(url,params) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment