How can I integrate checkboxes in a list view with jQuery Mobile?

How can I display the status of users with three different levels in a list view? I need to show whether they are attending or not, similar to the image provided. The issue is that currently the checkbox appears below the name, but I want it to be at the right corner marked with blue color.

Here is the code snippet:

<ul data-role="listview" data-filter="true" style="margin-right: 5px; margin-left: 5px;" id="progress_list" data-filter-placeholder="Filter Names">
<li data-icon="false" class="listitem"><a href="#" onClick='#'>Jashwin <input type="checkbox" name="submt_photo" id="submt_photo" class="custom" checked /><input type="checkbox" name="submt_Identity" id="submt_Identity" class="custom" /><input type="checkbox" name="submt_Address" id="submt_Address" class="custom" checked /></a></li>

Check out the demo on Fiddle here: http://jsfiddle.net/manjunath_r/eh6o90gp/

I would greatly appreciate it if someone could guide me on how to assign different colors to each checkbox.

Answer №1

Seems like the issue is due to the position: absolute; applied to

.ui-checkbox input, .ui-radio input
, causing them to overlap. Here's an updated version where they are displayed side by side http://jsfiddle.net/2mivs8x3/.

If you can modify the HTML code directly, you could make changes similar to this to move the inputs around. Check out this example http://jsfiddle.net/cg6oj9vz/ (Added a span around the User's name to float it to the left, as floating the inputs would switch their positions).

Answer №2

To achieve the jQM look and feel for checkboxes, you can implement the following methods:

Take a look at this DEMO to see both options in action

For a controlgroup appearance

<ul data-role="listview" data-filter="true" id="progress_list" data-filter-placeholder="Filter Names" class="has-right-radio">
    <li data-icon="false" class="listitem"> 
        <a href="#" onClick='#' class="ui-btn">Jashwin</a>
        <div data-role="controlgroup" data-type="horizontal" data-mini="true" class="right-radio">
            <label><input type="checkbox" name="submt_photo" id="submt_photo" class="custom" checked /> A</label>
            <label><input type="checkbox" name="submt_Identity" id="submt_Identity" class="custom" />B</label>
            <label><input type="checkbox" name="submt_Address" id="submt_Address" class="custom" checked />C</label>
        </div>
    </li>
</ul>

.has-right-radio a {
    padding-right: 124px !important;
}
.right-radio {
    position: absolute;
    top: 0px;
    bottom: 0px;
    right: 0px;
    width: 112px;
}
.right-radio .ui-checkbox input {
    visibility: hidden;
}

If individual checkboxes suit your needs better than toggle buttons:

<ul data-role="listview" data-filter="true" id="progress_list2" data-filter-placeholder="Filter Names" class="has-right-radio">
    <li data-icon="false" class="listitem"> 
        <a href="#" onClick='#' class="ui-btn">Jashwin</a>
        <div  class="right-radio">
            <label><input type="checkbox" name="submt_photo" id="submt_photo" class="custom" checked />&nbsp;</label>
            <label><input type="checkbox" name="submt_Identity" id="submt_Identity" class="custom" />&nbsp;</label>               
            <label><input type="checkbox" name="submt_Address" id="submt_Address" class="custom" checked />&nbsp;</label>
        </div>
    </li>
</ul>

#progress_list2 .has-right-radio a {
    padding-right: 132px !important;
}
#progress_list2 .right-radio {
    position: absolute;
    top: 0px;
    bottom: 0px;
    right: 0px;
    width: 120px;
    border: 1px solid rgb(204, 204, 204);
}

#progress_list2 .right-radio .ui-checkbox {
    display: inline;
    float: left;
    padding: 0;
    margin: 0;
}
#progress_list2 .right-radio .ui-checkbox label {
    padding-right: 0;
    padding-left: 36px;
    border:0;
    border-radius: 0;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using JQuery and/or Selenium/WebDriver to ascertain the visible color of elements on a webpage

Is there a way to accurately determine the visible color of page elements? When using JQuery, I can retrieve the background-color of an element with the following code: $('#foo').css('background-color'); However, the background-color ...

I am experiencing difficulty with the color of my progress bar in Firefox

After successfully creating an interactive progress bar that works perfectly in Google Chrome and surprisingly also in Safari without vendor prefixes, I encountered a roadblock when testing it on Firefox. The progress bar color reverts back to the default ...

The submission of the form is not possible with jQuery

Here is my code: $(document).ready(function(){ console.log("jquery is functioning"); // **** Global Variables **** //starting ingredient number for new ingredients $ing_num = 3; var new_label; var new_input; $("#add_icon").click(funct ...

Check to see if two words are identical in PHP

Could you please check the word I've written in the text field? If the two words are the same, I should receive a message saying "They are the same." <?php function array_random($arr, $num = 1) { shuffle($arr); $r = array(); for ($i = ...

What HTML element identifies the beginning of a particular section?

It has been suggested that Google frowns upon using identical content across multiple websites. Is there a method to mark or label a section of content with its "source"? For example, an attribute might look like this: <div original-content="http://s ...

Showing content from a JavaScript variable once a button has been clicked

Imagine you are using express.js and have a JavaScript variable embedded in an ejs file like this: <%= someVariable %> How can you display the value from this variable on the same page, for instance within a bootstrap modal element (check out https: ...

Clicking on a checkbox within an HTML table that incorporates handlebar and Express.js

My situation involves a HTML table within a form that is being populated with Handlebars. I need to be able to select certain rows in the table using checkboxes, and upon form submission through a POST request in an Express.js framework, I require the JSON ...

Implementing CSS injection on a Next.js page during server-side rendering - tips and tricks!

I recently started working with next js. In my _app.tsx page, I have the following code: import '../styles/antd.css' import '../styles/globals.css' import type { AppProps } from 'next/app' function MyApp({ Component, pagePr ...

Troubleshooting issue: Angular not resolving controller dependency in nested route when used with requirejs

When the routes are multiple levels, such as http://www.example.com/profile/view, the RequireJS is failing to resolve dependencies properly. However, if the route is just http://www.example.com/view, the controller dependency is resolved correctly. Below ...

Global style applied to image property

Within my CSS file, I have a property (shown below) that is set to apply to all images: img{height:auto;max-width:100%;} However, I have a specific div where I do not want this property to apply to the images within it. Even after assigning a new image c ...

Angular 7 routing glitches causing page refresh issues

Here is the issue I'm facing: I am looking for a way to switch between tabs in my navigation bar without having to refresh the entire website. I have just started working with Angular and I believe that the router should be able to route to a new pag ...

What could be causing my insertRow function to inject empty cells into my table?

I am facing an issue with adding the results of a fetch request into a table as a new row. Strangely, when I click the button to trigger this function for the first time, it adds an empty row instead of the desired data. However, on subsequent clicks, the ...

Nested jQuery UI Selectable causing propagation problems

My issue lies in the nested jQuery UI selectable functionality. When I click on Item 1, it is selected as expected. However, when clicking on Item 111 or 1111, it selects all the way up to Item 2. What I require is for only the element that is clicked on t ...

Having trouble with JQuery Draggable in FireFox only working in an iFrame? Learn how to set the ViewPort to fix

Having trouble with jQuery UI Draggable in FireFox 33.0.2: I followed the example code, but it doesn't seem to be working. The scripts are running, CSS classes are added, event bindings are in place, but dragging won't work. I noticed that when ...

jQuery Autocomplete API Issue: Undefined

I've been attempting to implement a basic text box using the jQuery API from DevBridge. I followed instructions in this video tutorial to create my code. However, despite properly declaring scripts before the JS code and ensuring proper mappings, I&a ...

Unable to retrieve the value from a textarea when using Shopify Product Options by Bold

I'm currently facing an issue trying to retrieve the value of a textarea using Shopify's Product Options by Bold. The code works fine locally, but when I transfer it over to Shopify, I am unable to get the value. Despite looking at various resour ...

Styling Material UI components with CSS is a great way to

I'm facing difficulties while working with Material UI components. Currently, I have a Material UI table and I want to center-align the text within it. The standard CSS of Material UI contains an element named MuiTableCell-root-60 which has a text-a ...

Is there a way to display the true colors of a picture thumbnail when we click on it?

In my project, I attempted to create a dynamic color change effect when clicking on one of four different pictures. The images are displayed as thumbnails, and upon clicking on a thumbnail, it becomes active with the corresponding logo color, similar to t ...

Design images with rounded corners using CSS

I'm looking to design an image avatar similar to the contact avatars on Skype. Can someone assist me with this? I have tried using border radius-boundary, but I haven't had much luck. ...

Feature of Thymeleaf: Download functionality

When working with my Thymeleaf template, I have successfully processed Java map content to HTML using the following code: <div th:each="file : ${files}"> <span th:text="${file.key}"></span> <!-- here file.key is retrieved --> ...