Skip to main content

Jquery Mobile Form - Select Menus Part I

    Today we will take a look at the select boxes styling and usage using Jquery Mobile. Select menus has a little more explanation and examples than other controls and so I am dividing the select menus tutorial into 2 parts. In the first part, we will take a look at the basics of the Jquery Mobile select menus and in the second part we will take a look at the more complex examples involving the select menus.

    The Jquery Mobile select menu is based on the native HTML select element, which is styled and modified to suite the Jquery Mobile framework's style. By default, the framework leverages the native OS options menu to use with the custom select button. When the button is clicked, the native OS menu will open. When a value is selected and the menu closes, the custom button's text is updated to match the selected value. The framework also offers the possibility of having custom (non-native) select menus; which we will discuss in part 2 of this tutorial. Refer to the screenshots below to understand how the native select menus work.

The Native menu - Android 4.1.1/ HTC One X


The Native menu - iPhone 4S/ iOS 6.1.3


    The select boxes can be used singularly or in a vertical group or can be even grouped horizontally. These select boxes can be used along with data-mini="true" too, which renders the select boxes in a smaller size. We will take a look at all this in the example that follows.


    The first implementation of the select box in the above code is the regular, simple select box. The framework styles this select element as per the Jquery Mobile framework styles displaying a button with custom down arrow and using the native OS menu. The second implementation is exactly similar to the first one with the only difference of data-mini="true" attribute. Addition of this data attribute to the select element renders a smaller select box..

    In the next implementation we have the label and the select box aligned side-by-side. To achieve this, we need to wrap the select element with in a div with data-role="fieldcontain". Adding this data attribute to the div tells the framework to align the label and the select box side-by-side.

    In the fourth implementation we have the regular select element with the optgroup used for the options. Including options within the optgroup element, groups these options visually under a single optgroup label. However, the support for this feature in mobile selects is a bit spotty, but is improving by the day.

    Multiple select boxes can be grouped together like checkboxes or radio buttons to achieve visual grouping of the select elements. The select boxes can be grouped vertically as well as horizontally. To achieve this the select elements need to be wrapped within a fieldset element with data-role="controlgroup". Doing this would group the select boxes vertically (which is the default grouping technique). To group the select boxes horizontally as seen in the last implementation, you need to add another data attribute data-type="horizontal" to the fieldset element.

    For the sake of accessibility, jQuery Mobile requires that all form elements be paired with a meaningful label. To hide labels in a way that leaves them visible to assistive technologies. — for example, when letting an element's placeholder attribute serve as a label — apply the helper class ui-hidden-accessible to the label itself. While the label will no longer be visible, it will be available to assisitive technologies such as screen readers.

    Hope this post has cleared out your basics of the Jquery Mobile select menus. In part 2 of this tutorial, we will take a look at the advanced select menu options where we can override the default menu behavior and create differently styled select menus. Stay tuned for the advanced topics on select menus in the next post and you can also look at the complete list of Jquery mobile listview and form elements examples. Fun is on it's way!

Comments

Recommended for You

Where does Google get it's live traffic data from?

Referring to a post that I wrote earlier, Google’s - Live traffic Layer , ever wondered how Google collected this data? I was wondering the other day, how Google received live data to display it on their maps as a layer! I looked up the web and found something very interesting and am sharing the same with you all. As we all know, the traffic layer is available most accurately in several states in USA. Most major metro areas in the US have sensors embedded in their highways. These sensors track real time traffic data. Easy to miss at high speeds (hopefully anyway, traffic permitting), more commonly noticed may be the similar sensors that often exist at many busy intersections that help the traffic lights most efficiently let the most amount of people through. The information from these tracking sensors is reported back to the Department of Transportation (DOT). The DOT uses this data to update some of the digital signs that report traffic conditions in many metro areas. They als

Playing with the markers and info window bubbles...

    In the last few posts, we have seen some marker examples and some information window examples. Now, lets do something interesting combining these two things. Just writing that "This is an info window" in the information bubble is not very interesting! And I know this...Have gone through the same phase!     So, today we will do something interesting! We will display the latitude- longitude co-ordinates of the point that the user clicks on the map! Doing this is not at all complex! Copy paste the following code and you will see for yourself a map coming to life!     The output of the above code looks as seen in the result section above! If you have any queries regarding the above code please comment on the blog post or feel free to contact me at my mail ID .

Integrated GPS cameras...

          GeoSpatial Experts has introduced three new GPS Camera bundles designed specifically for geotagging and mapping digital photographs. The firm now offers its popular GPS-Photo Link 5.0 photo-mapping software with the new Ricoh G700SE, Sony A55, and Casio EX-H20G GPS cameras.           All of the GPS cameras below will provide you with geotagged photos, additionally, some can also offer the ability to capture the direction the photo was taken with a built-in compass, or the ability to collect attribute data in the field. WiFi and Bluetooth will allow you to communicate with laser range finder equipment to measure exact distance from the photographer to the item being photographed. Some GPS cameras provide a ruggedized camera to withstand harsh conditions.            In 2007, Ricoh introduced its 500SE model as the first GPS-equipped SLR designed for GIS data collection, and the new G700SE is more compact and offers many upgrades. Fully ruggedized and waterproo

Ground Truth - How Google Builds Maps

    Todays's article is cross posted from The Atlantic 's Tech section. The article was posted by Alexis Madrigal who is a senior editor at The Atlantic , where he oversees the Technology channel. So, thanks to The Atlantic and Alexis Madrigal, we will have an exclusive look inside Ground Truth , the secretive program to build the world's best accurate maps.     Behind every Google Map, there is a much more complex map that's the key to your queries but hidden from your view. The deep map contains the logic of places: their no-left-turns and freeway on-ramps, speed limits and traffic conditions. This is the data that you're drawing from when you ask Google to navigate you from point A to point B -- and last week, Google showed me the internal map and demonstrated how it was built. It's the first time the company has let anyone watch how the project it calls GT, or "Ground Truth," actually works.     Google opened up at a key moment in its evo

Google Street View Image API

    Street View is one of most used feature of the Google Maps and why not? You can actually see any part of the world as if you are visiting the place at that very moment. And now with the Google Street View Image API, you don't even need to carry a camera with you to the places you visit. You can take-in all the scenic beauty without even bothering about clicking a single picture. You can come back from your vacation and get a few images using the Google Street View Image API and show those images to your friends and relatives. Create an album of high definition images and go ahead and share it on Facebook for your friends to have a look.     Using the Google Street View Image API is very simple and anybody can make use of it without any programming knowledge required. I will walk you through the entire process of effectively using the Google Street View Image API. So if you are set, let's go on an amazing ride across the globe with the Google Street Views.     The Go