动态生成的列表项打开动态页面 jQuery Mobile
我有一个用 PHP 生成的列表。
<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>
它按照预期列出了所有内容。但我希望每个列表项打开一个对话框,其中包含严格针对该客户的信息。那么,我是否稍后在页面中运行另一个 SQL 语句,创建更多带有与名称或其他内容匹配的 id 的
?或者有没有办法通过 ajax 调用每个信息,例如:echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';
I have a list generated with PHP.
<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>';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你可以这样做:
文档:
http://jquerymobile.com/demos/1.0a4.1/#docs/toolbars/../../docs/pages/docs-dialogs.html
所以你的代码应该工作:
Yep you can do it this way:
The Docs:
http://jquerymobile.com/demos/1.0a4.1/#docs/toolbars/../../docs/pages/docs-dialogs.html
So your code should work: