Showing posts with label groupby. Show all posts
Showing posts with label groupby. Show all posts

Monday, June 30, 2014

Processing Form Data with jQuery and Lodash

I can get most of what I need for processing form data straight out of jQuery. I can listen for the submit event on the form, and I can prevent the form from actually getting submitted, allowing my own behaviour to run. jQuery also helps me collect the form data I need with the serializeArray() function. This function returns an array of form values. Lodash can help me transform this array into something more usable.

Monday, March 17, 2014

Classification With Lodash groupBy()

It's seldom that the API data returned by your application server will have everything you need to render the user interface you're after. Do you ask the API team to extend the data schema to fit your front-end design? Not unless the rewards are huge. And sometimes that's the case. For example, if there's a field that the front-end code needs, and has to jump through hoops in order to get, then you obviously benefit from having the field as part of the API. Especially if it's used everywhere in the UI. What's more common, however, are the edge-cases where we need some piece of data that just isn't part of the API. Extending the API is just way too much effort — much greater than the reward. An example of this type of front-end manipulation is classifying data with the help of lodash.groupBy().