Search code examples
jquery-mobilejquery-mobile-listview

How can I move the caption on top in a jQuery Mobile ListView


Given the example jquery mobile listview form

enter image description here

<form>
    <ul data-role="listview" data-inset="true">
        <li data-role="fieldcontain">
            <label for="name2">Text Input:</label>
            <input type="text" name="name2" id="name2" value="" data-clear-btn="true">
        </li>
        <li data-role="fieldcontain">
            <label for="textarea2">Textarea:</label>
        <textarea cols="40" rows="8" name="textarea2" id="textarea2"></textarea>
        </li>
        <li data-role="fieldcontain">
            <label for="flip2">Flip switch:</label>
            <select name="flip2" id="flip2" data-role="slider">
                <option value="off">Off</option>
                <option value="on">On</option>
            </select>
        </li>
        <li data-role="fieldcontain">
            <label for="slider2">Slider:</label>
            <input type="range" name="slider2" id="slider2" value="0" min="0" max="100" data-highlight="true">
        </li>
        <li data-role="fieldcontain">
            <label for="select-choice-1" class="select">Choose shipping method:</label>
            <select name="select-choice-1" id="select-choice-1">
                <option value="standard">Standard: 7 day</option>
                <option value="rush">Rush: 3 days</option>
                <option value="express">Express: next day</option>
                <option value="overnight">Overnight</option>
            </select>
        </li>
        <li class="ui-body ui-body-b">
            <fieldset class="ui-grid-a">
                    <div class="ui-block-a"><button type="submit" data-theme="d">Cancel</button></div>
                    <div class="ui-block-b"><button type="submit" data-theme="a">Submit</button></div>
            </fieldset>
        </li>
    </ul>
</form>

How can I move the captions above the form elements?

enter image description here

My reason is that I have a thin list view inside (what used to be) a jQuery panel. I'm avoiding using true jqm panels because of issues with having multiple panels open at once, on a desktop app.

I'm using listviews so I can add grouping lines to the form, to increase readability.


Solution

  • Remove data-role="fieldcontain" from your li elements