background preloader

Forms & Validation

Facebook Twitter

Show/hide Login and Signup Panel using Mootools 1.2. AngularJS in depth Part 2 Filters. OrderBy and filter Filters The filter named as filter is used for selecting a subset of an array in AngularJS.

AngularJS in depth Part 2 Filters

The two requirements for performing a filtering are the array to filter and a predicate. The predicate in the case of AngularJS could be a string, an object, or a function. The rest of this setion will walkthrough creating a small application and applying different filters. Let’s quickly create the HTML boiler plate code required for the sample application. <! HTML file is very simple, it references AngularJS, Bootstrap, and our to be written AngularJS application files. Using Bootstrap layout styles we have created a container for our table. The only dependency for our application is ngResource and our app module takes care of fulfilling that dependency as we have already placed the JavaScript file for ngResource. Bringing Order We can use orderBy filter to provide the sorting functionality for the table we have just created. 1.

Filtering json, lowercase, and uppercase Filters. How to make a custom filter in AngularJS ? - iViveLabs. Sorting by Multiple Fields with Different Sort Orders Using the AngularJS orderby Filter. I’m working on a new, interactive, interface to the $100,000 Club dataset I keep on itsalljustcomics.com.

Sorting by Multiple Fields with Different Sort Orders Using the AngularJS orderby Filter

The data deals with the world’s most valuable comic books (those worth more than $100,000) and it’s always just been a static list. Since I’ve started keeping track of that data, the number of entries has steadily grown to include hundreds of books. Because of that growth and in concert with the relaunch of that site, I’ve started to put together an AngularJS based interface to the data. One of the things I need to do is sort the displayed data by three different fields and with two different sorts.

Forms in AngularJS.pdf - Microsoft Word Web App. Filters in AngularJS. The concepts of AngularJS Forms. Creating HTML form is quite easy for developers like us and I’m sure we don’t need to talk it again here since there are plenty of HTML form tutorial out there.

The concepts of AngularJS Forms

Don’t worry we are not going to talk about plain HTML form, we are going to understand form in the context of Angular. Your understanding of plain HTML form will be a prequisite here. This article also requires basic angular knowledge, If you don’t have any idea what angular is, you should read my post on angular overview first before continuing. The goal of an application is to help people, by using an application people or users want to accomplish their tasks. AngularJS: $watch, $digest and $apply.

While browsing reddit, I read an article I felt over-complicated an explanation of $watch, $digest and $apply, and perhaps gave people a little bit of the wrong idea about what it is.

AngularJS: $watch, $digest and $apply

What is a $watch? Let's talk about this first. $watch is arguably the most important internal feature of Angular. Filters. Group and Display Data with Underscore and AngularJS. Let’s use the following data to simulate information you might receive from an HTTP API: Using underscore.js, it is easy to group the objects by their department attribute.

Group and Display Data with Underscore and AngularJS

Now $scope.groups will look like the following: One way to get the data onto the screen is to use an ngRepeater, but the most popular expression form for the repeater (”variable in expression”) doesn’t exactly give us what we want. That’s because department will hold each value of the groups collection. What we really want is the lesser known expression supported by Angular: (key, value) in expression. Which gives us: As always, there are 101 ways to achieve this end result, but I rather like the (key, value) expressions myself. Codebrag. Written byMichał Ostruszka As AngularJS is one of the tools in Codebrag's toolbox, you can expect some technical posts related to our development process with it.

Codebrag

Let’s start with the first one below. You know the case when you hit submit button quickly enough that it sends the form twice? Or when you hit submit button and it seems that nothing happens, so you click it once again and another request is being fired? Duplicated requests issue - you can experience it in both traditional web application as well as in modern so-called Single Page Applications. The traveling hermit: AngularJS Missing Directives: Native Form Resets. If you haven't played around with AngularJS yet, I highly advise you give it a try.

The traveling hermit: AngularJS Missing Directives: Native Form Resets

There are plenty of introductory articles and videos out there that will whet your appetite and get you up and running (here, here and here to name a few). Go ahead, go play. This post will still be here later when you need it. And you will need it. Okay, for everyone else, after the excitement and wonderment of two-way binding begins to wane you will start to notice some of the peculiarities about AngularJS.

Get person's age in Ruby. Age calculation in Ruby. How to calculate how many years passed since a given date in Ruby. Calculate age in Rails with a birthday. "Birthday" gem for easy anniversaries handling. While working on one of our client projects, I was asked to create a search for users' birthdays.

"Birthday" gem for easy anniversaries handling

Instantly, I remembered what problems I had with it in the past, like taking care of not only finding the right dates by only day and month, but also, checking for birthdays today, any upcoming birthdays, or even just looking up user's age based on that information. So, to never ever repeat that code again (and to keep the code DRY), I've decided to write a simple gem specifically for this stuff.

And thus the birthday gem was born. Requirements The gem has been tested against Rails 3 (3.0.9) and Rails 2 (2.3.14), and depends on ActiveRecord and ActiveSupport (for inflections), making it a perfect fit for Rails. The gem works with MySQL and PostgreSQL adapters, but you can write your own adapters, if you need to. So, how does it actually work? Angularjs - Two way binding of contenteditable item inside ng-list. Rails 3.2: A Nested-Form Demo, Part 1: All Wings Report In!

Background I've been working on a Rails 3.2 project for the last several months.

Rails 3.2: A Nested-Form Demo, Part 1: All Wings Report In!

While it's been a blast to learn a new technology stack (I've spent most of my career working with .NET), there have definitely been some bumps in the road. In particular, I've spent the last couple weeks working on persisting a model that has a parent-child relationship. The bulk of that time was spent poking around the inter-webs, looking for tips and tricks to accomplish my goal. During my inter-web search, I couldn't find a single post (or series of posts) that had a complete example or tutorial on how to persist a model that has a parent/child relationship. Objective/Goals Reading is real neat, and I do a whole lot of it. The Application Most demo apps I see deal with users, customers, security groups and the like.

Initially, the concept for our initial application is very simple: Angular.js Nested Repeatable Example » Jacob Mumm. A little while ago, I was working on a fairly simple form builder.

Angular.js Nested Repeatable Example » Jacob Mumm

I wanted repeatable sections with repeatable questions. Starting with traditional JavaScript/jQuery, I quickly had about a hundred lines of code. I was waist deep, but I could see the end was only another hundred lines or so away. Adding and Removing Children with Rails Nested Forms and AngularJS. AngularJS had appeared on my radar before, but I wasn’t inspired to try it until I read Click to Edit with AngularJS by Tim Riley. AngularJS takes a different approach to enhancing pages. Instead of thinking about DOM manipulation, you think about data and bindings. How to Easily Validate Any Form Ever Using AngularJS.

If you’ve ever tried to build any kind of website, odds are you’ve had to create some way of validating and saving input from a form. Back in the bad old days this used to be a huge pain, because there were no good frameworks to help get the job done right. The three primary pain points that you have to deal with when trying to validate a form without the aid of a framework are: Pain Point #1. ActiveRecord: When aggregating nested children, always exclude children marked for destruction. Posted about 2 years ago. Visible to the public. Repeats. When your model is using a callback like before_save or before_validation to calculate an aggregated value from its children, it needs to skip those children that are #marked_for_destruction?. Slice a nested hash. Accept nested attributes for a record that is not an association.

Form - Nested Repeatable Objects - Params (source? > jacob mumm?) Angular.js Nested Repeatable Example » Jacob Mumm. Good real world example for form models / presenters in Rails. Posted 12 months ago. Visible to the public. We have often felt the pain where our models need to serve too many masters. EzMark jQuery Plugin - Stylize Checkbox and Radio Button Easily. Fancy Sliding Form with jQuery.

Using ngResource with AngularJS - Jaco Pretorius. In my first post on AngularJS I created a simple Todo application with a Rails/Mongo RESTful server. In this application I was doing all my ajax calls manually (which is really easy in Angular), which meant most of my controller methods looked like this: Form Text Input - Params. Form Text Input Box - Placeholder Text (guide user) Form Input Decorators - Params. Form Elements - Enable/Disable. Submit/Form, etc.

Ng-class - form example (broke) Clear Form Element ('Pristine') AngularJS Form Validation. Submit Params. Form Params. Truncate Filter for AngularJS v1. Selection/Filter. Form validation 1. Form Submission.