动态生成的列表项打开动态页面jQuery Mobile

时间:2011-05-05 04:23:44

标签: 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语句,创建更多<div data-role="page">,其ID与名称相匹配?或者有没有办法通过ajax调用每个信息,如:

echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';

1 个答案:

答案 0 :(得分:1)

是的,你可以这样做:

<a href="foo.html" data-rel="dialog">Open dialog</a>

文件:

http://jquerymobile.com/demos/1.0a4.1/#docs/toolbars/../../docs/pages/docs-dialogs.html

所以你的代码应该有效:

echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';