Got a listview with left aligned icon.
Unable to bind 'click' to icon.
Able to get all icon's span with selector.
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css"/>
- <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
- <script>
- $('#home').live('pageshow', function (event, ui) {
- console.log($.mobile.activePage.children(":jqmData(role=content)").find("UL").find("span.ui-icon"));
- $.mobile.activePage.children(":jqmData(role=content)").find("UL").find("span.ui-icon").bind("click", function (e) {
- alert("Icon clicked");
- e.preventDefault();
- e.stopPropagation();
- });
- });
- </script>
- <style>
- .ui-btn-hover-c.ui-btn-up-c.ui-btn-active span.ui-icon-arrow-r {background-position: -355px 0%;}
- .ui-btn-up-c .ui-icon, .ui-btn-hover-c .ui-icon {
- left: 10px;
- }
- li a {
- padding-left: 35px!important;
- }
- </style>
- </head>
- <body>
- <div data-role="page" class="type-index" id="home">
- <div data-role="content">
- <ul data-role="listview" data-inset="false" data-theme="c">
- <li><a href="#">Item1</a></li>
- <li><a href="#">Item2</a></li>
- <li><a href="#">Item3</a></li>
- </ul>
- </div>
- </div>
- </body>
- </html>