Skip to content

Instantly share code, notes, and snippets.

@ovaillancourt
Created April 13, 2012 01:08
Show Gist options
  • Save ovaillancourt/2372523 to your computer and use it in GitHub Desktop.
Save ovaillancourt/2372523 to your computer and use it in GitHub Desktop.
I love javascript
//Javascript magic here
//We grab the value from the dom element, split it in terms where every
//term is delimited by a comma, then trim every term, re-combine them
//together using a comma as separator and then URI encode the whole thing.
var fieldVals = encodeURIComponent(
this.$('#product_search #field_val').val().split(',').map(function(v){
return v.trim();
}).join(',')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment