Dynamically generated List Items Opens Dynamic Page jQuery Mobile
I have a list generated with P开发者_如何学JAVAHP.
<ul data-role="listview" data-filter="true" data-inset="true">
<?
$qry = "SELECT jobname, jobsurname, LEFT(jobsurname, 1) AS first_char FROM clients WHERE UPPER(LEFT(jobsurname, 1)) BETWEEN 'A' AND 'Z' OR LEFT(jobsurname, 1) BETWEEN '0' AND '9' ORDER BY jobsurname";
$result = mysql_query($qry);
$current_char = '';
while ($row = mysql_fetch_assoc($result)) {
if ($row['first_char'] != $current_char) {
$current_char = $row['first_char'];
echo '<li data-role="list-divider">' . strtoupper($current_char) . '</li>';
}
echo '<li><a href="#">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';
}
?>
</ul>
It lists everything like its supposed to. But I want each list item to open a dialog with the information strictly for that client. So do I run another SQL statement later on in my page creating more <div data-role="page">
with an id matching the name or something? Or is there a way to call each info via ajax like:
echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';
Yep you can do it this way:
<a href="foo.html" data-rel="dialog">Open dialog</a>
The Docs:
http://jquerymobile.com/demos/1.0a4.1/#docs/toolbars/../../docs/pages/docs-dialogs.html
So your code should work:
echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';
精彩评论