Deeplinking

Home Search

Deeplinks

This page shows how to use deeplinks (links that scroll to an ID) within JQM

While deep links are not currently supported by jQuery Mobile Using a very small event binding you can make them work for most situations.

Links which will scroll to an id on the same page all you need to do is set data-ajax="false" on the link and use the id for the href like normal here is an example

To make a link that goes to a an id on another page you just add the query param scrollto=idToScrollTo to the end of your link

To Make a link that will scroll to the top of the page just set an id on your body tag of top and link to that id with data-ajax="false" href="#top"

Important: The rest of the page is just example usage

This page is not a refrence for the slider widget it is just sample content do not refrence this page for slider widget usage! For the slider widget please see Slider Widget

Slider

Jump To: Step Increment, Fill Highlight, Mini version, Field Containers, Calling the slider, Theming the slider

To add a slider widget to your page, use a standard input with the type="range" attribute. The input's value is used to configure the starting position of the handle and the value is populated in the text input. Specify min and max attribute values to set the slider's range. If you want to constrain input to specific increments, add the step attribute. Set the value attribute to define the initial value. The framework will parse these attributes to configure the slider widget. View the data- attribute reference to see all the possible attributes you can add to sliders.

As you drag the slider's handle, the framework will update the native input's value (and vice-versa) so they are always in sync; this ensures that the value is submitted with the form.

Set the for attribute of the label to match the id of the input so they are semantically associated. It's possible to accessibly hide the label if it's not desired in the page layout, but we require that it is present in the markup for semantic and accessibility reasons.

The framework will find all input elements with a type="range" and automatically enhance them into a slider with an accompanying input without any need to apply a data-role attribute. To prevent the automatic enhancement of this input into a slider, add data-role="none" attribute to the input and wrap them in a div with the data-role="fieldcontain" attribute to group them. In this example, the acceptable range is 0-100.


<label for="slider-1">Input slider:</label>
<input type="range" name="slider-1" id="slider-1" value="60" min="0" max="100" />

The default slider with these settings is displayed like this:



return to top

Step increment

To force the slider to snap to a specific increment, add the step attribute to the input. By default, the step is 1, but in this example, the step is 50 and the maximum value is 500.


<label for="slider-step">Input slider:</label>
<input type="range" name="slider-step" id="slider-step" value="150" min="0" max="500" step="50" />

This will produce an input that snaps to increments of 50. If a value is added to the input that isn't valid with the step increment, the value will be reset on blur to the closest step.



return to top

Fill highlight

To have a highlight fill on the track up to the slider handle position, add the data-highlight="true" attribute to the input. The fill uses the active state swatch.


<label for="slider-fill">Input slider:</label>
<input type="range" name="slider-fill" id="slider-fill" value="60" min="0" max="100" data-highlight="true" />


return to top

Mini version

For a more compact version that is useful in toolbars and tight spaces, add the data-mini="true" attribute to the element to create a mini version.


<label for="slider-mini">Input slider:</label>
<input type="range" name="slider-mini" id="slider-mini" value="25" min="0" max="100" data-highlight="true" data-mini="true" />

This will produce a slider and its corresponding input that are not as tall as the standard version. The input also has a smaller text size.



return to top

Field containers

Optionally wrap the slider markup in a container with the data-role="fieldcontain" attribute to help visually group it in a longer form. In this example, the step attribute is omitted to allow any whole number value to be selected.


<div data-role="fieldcontain">
   <label for="slider-2">Input slider:</label>
   <input type="range" name="slider-2" id="slider-2" value="25" min="0" max="100"  />
</div>

The slider is now displayed like this:

Sliders also respond to key commands. Right Arrow, Up Arrow and Page Up keys increase the value; Left Arrow, Down Arrow and Page Down keys decrease it. To move the slider to its minimum or maximum value, use the Home or End key, respectively.



return to top

Calling the slider plugin

This plugin will auto initialize on any page that contains a text input with the type="range" attribute. However, if needed you can directly call the slider plugin on any selector, just like any jQuery plugin:


$('input').slider();


return to top

Theming the slider

To set the theme swatch for the slider, add a data-theme attribute to the input which will apply the theme to both the input, handle and track. The track swatch can be set separately by adding the data-track-theme attribute to apply the down state version of the selected button swatch.


<div data-role="fieldcontain">
	<label for="slider-3">Input slider:</label>
	<input type="range" name="slider-3" id="slider-3" value="25" min="0" max="100" data-theme="a" data-track-theme="b" />
</div>
		

This will produce a themed slider:



return to top