jQuery UI Widgets
Illustration by John Hersey

Solution: Upgrade the contact form


From:

jQuery UI Widgets

with Joe Chellman

Video: Solution: Upgrade the contact form

This challenge for jQuery UI came in three parts. First, to convert these elements into an Accordion, to add a Date Picker, and to make these check boxes sortable. Let's take a look at my solution. So, here is the Accordion. Works fine. And this is the Date Picker. Now as you can see, we have a minimum date. You can select anything that's tomorrow or later. And then here, under General Information, I can check the tours that I like.

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course jQuery UI Widgets
33m 53s Intermediate Nov 11, 2013

Viewers: in countries Watching now:

Despite the possibilities offered in HTML5, there's still a call for customizable widgets that can be used in websites and web apps. jQuery UI, a popular plugin for jQuery, is here to answer that call. Joe Chellman shows how to install the plugin, use the accordion and date picker widgets, and add behaviors that change how existing page elements respond to user input. Finally, you'll apply the concepts you've learned to a typical project you might see coming from a client—a survey form.

This course is a short companion piece to jQuery for Web Designers. See that course for information about building your core jQuery skill set.

Subject:
Web
Software:
jQuery
Author:
Joe Chellman

Solution: Upgrade the contact form

This challenge for jQuery UI came in three parts. First, to convert these elements into an Accordion, to add a Date Picker, and to make these check boxes sortable. Let's take a look at my solution. So, here is the Accordion. Works fine. And this is the Date Picker. Now as you can see, we have a minimum date. You can select anything that's tomorrow or later. And then here, under General Information, I can check the tours that I like. And I can also drag them to the top, put them in the order that I think interests me. And then submit it.

No extra processing, but I can do it right here. Let's see how this is implemented. So first of all we need to see the Markup. Here is the Opening Form tag. Now what I've done is I've added a wrapper DIV around everything here. JQuery UI's Accordion widget requires a container on which you're going to instantiate the accordion. And then you just need some element that will serve as the Header, followed by another container for whatever the content is. In this case, the form was already using Field Set tags, so I just kept those. But I added a Header beforehand.

The tricky thing about this is that it was built with the Legend tag on the inside. Which is the sensible part of a field set for accessibility purposes. But when we turn this into an accordion, it doesn't make sense so much because we end up seeing this twice. So I added some CSS to the top here to make sure that that would not show up, when in the context I would instantiated jQuery UI Accordian widget. Looking at the browser, I'll show you how that works. Inspect this, and you can see, after jQuery UI is instantiated, it adds a ton of classes to all these different elements. This isn't here before jQuery UI is instantiated.

But I can use that for when it is displayed, to hide the Legend. So that's the structure of the HTML. Now if I jump down to my JavaScript, we already had jQuery UI instantiated on the CSS that was needed for this particular small custom theme. Then it was just a matter of enabling the things that I needed. So first, I enabled the Accordion. And when it started out. I'll take this option out and save it. It first looked like this, with all this extra stuff down here. This is because the Accordion widget likes to make sure, by default, that all panes are the exact same size.

We didn't want all this extra stuff. So, I set the Height Style option to Content. You can see this on the Accordion API page. This option tells jQuery UI, don't try to make everything the same size, just make each pane as big as its content. And then here, I'm instantiating the Date Picker. The Min Date option is the right one to set a minimum date. You can set it to a hard-coded date, like this. You can also use Offsets. The example they give in the API is yesterday, where you can pass in negative one.

I want it tomorrow, so instead I used one. If you want it today you could use zero, if you want it next week you could use a seven. There are a variety of date formats that this Min Date option will accept, the easiest one for tomorrow I think, is just one. And then finally on this Check Box Preference group, which is the ID that surrounds all these check boxes right here. I just enabled Sortable and additionally chained on the Disabled Selection so we don't end up with accidental extra text selection.

And so the result is a nice Accordion with the sortable options and my Date Picker.

There are currently no FAQs about jQuery UI Widgets.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed jQuery UI Widgets.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.