jQuery Mobile - Listview Split buttons



Description

Include a second link inside the li to create split list item. data-split-icon attribute is used to adjust the split button icon and data-split-theme attribute is used to include theme for the split button.

Example

Following example demonstrates the use of split button in the list in the jQuery Mobile.

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <h2>Listview Split Button Example</h2>
      <ul data-role = "listview" data-split-icon = "gear" data-split-theme = "a" 
         data-inset = "true">
         <li><a href = "#">
            <img src = "/jquery_mobile/images/facebook.jpg">
            <h2>Facebook</h2>
            <p>Mark Zukerburg</p></a>
            <a href = "#purchase" data-rel = "popup" data-position-to = "window" data-transition = "pop">Login</a>
         </li>
         
         <li><a href = "#"><img src = "/jquery_mobile/images/twitter.jpg">
            <h2>Twitter</h2>
            <p>Jack Dorsey</p></a>
            <a href = "#purchase" data-rel = "popup" data-position-to = "window" data-transition = "pop">Login</a>
         </li>
         
         <li><a href = "#"><img src = "/jquery_mobile/images/google.jpg">
            <h2>Google+</h2>
            <p>Google</p></a>
            <a href = "#purchase" data-rel = "popup" data-position-to = "window" data-transition = "pop">Login</a>
         </li>
      </ul>

      <div data-role = "popup" id = "purchase" data-theme = "a" data-overlay-theme = "b" 
         class = "ui-content">
         <h3>Social Media Sites</h3>
         <p>Login in your mobile device</p>
         <a href = "index.html" data-rel = "back" class = "ui-shadow ui-btn ui-btn-b ui-icon-check 
            ui-btn-icon-left ui-btn-inline ui-mini">LOGIN</a>
         <a href = "index.html" data-rel = "back" class = "ui-shadow ui-btn ui-btn-inline 
            ui-mini">Cancel</a>
      </div>
   </body>
</html>

Output

Let's carry out the following steps to see how the above code works −

  • Save the above html code as listview_split_buttons.html file in your server root folder.

  • Open this HTML file as http://localhost/listview_split_buttons.html and the following output will be displayed.

jquery_mobile_widgets.htm
Advertisements