Search code examples
phpjquery-mobile

jQuery-mobile 1.4.5 dynamic listview duplicate autodividers


I have a little problem with my application. I'm using jQuery-Mobile 1.4.5 and I want to use a listview with autodividers, filled with a SQL field in a PHP variable.

The problem is that autodividers titles are duplicating every time the SQL result finds a name with the same first letter.

As you can see in the next link, the image shows 2 autodividers generated with the "I" first letter, and I don't know why the lisview doesn't agroup them in only 1 autodivider.

https://1drv.ms/i/s!AmWUBgKqLm-KhjIOlqMJH9Nu1Odb

This is the code of my main div, which generates the dynamic autodivider with the PHP variable:

<div data-role="main" class="ui-content">
<h2>Listado de ventas por cliente</h2>
<form class="ui-filterable">
<input id="myFilter" data-type="search" placeholder="Buscar cliente">
</form>
<?php
while ($row = $res->fetch()) {
echo'<ul data-role="listview" data-filter="true" data-input="#myFilter" data-autodividers="true" data-inset="true">
<li><a href="#">'.$row[0].'</a></li>
</ul>';
}
?>
</div>

Any help is welcome.


Solution

  • You are using multiple data-autodividers.Use following code:

    <div data-role="main" class="ui-content">
    <h2>Listado de ventas por cliente</h2>
    <form class="ui-filterable">
    <input id="myFilter" data-type="search" placeholder="Buscar cliente">
    </form>
      <ul data-role="listview" data-filter="true" data-input="#myFilter" data-autodividers="true" data-inset="true">
    <?php
    while ($row = $res->fetch()) {
    echo'<li><a href="#">'.$row[0].'</a></li>';
    }
    ?>
        </ul>
    </div>