使用jquery模式框和ajax显示单元格表中的值

时间:2013-01-29 01:27:17

标签: jquery html jquery-ui grails modal-dialog

我正在尝试使用Jquery模式对话框将值传递给控制器​​来执行UPDATE函数。但是,我在HTML表格框中显示我的值,有没有办法将值从表格行传递到模态框?我想以某种方式执行此操作,当我单击该行时,值将显示在模态中。我也不确定如何将jquery对话框链接到表格行。

这是表格

enter image description here

这些是它的代码

<form id="searchtable" >
               <%--List Table--%>
               <table border = 1 cellpadding = 2  cellspacing = 2 id="normal">
              <tr>
                 <th width=9.7%>ID</th>
                 <th width=24%>Username</th>     
                 <th width=13%>Account ID</th>
                 <th width=29%>Email</th>
                 <th width=10%>User ID</th>
                 <th width=12%>Device ID</th>         
              </tr>
         </table>

              <div style="height: 250px; overflow: scroll; width: 100%;">
              <table id="normal">
              <g:each in = "${result}">
              <tr>
              <td width=10%>${it.ID}</td>
              <td width=25%>${it.Username}</td>
              <td width=13.5%>${it.account_id}</td>
              <td width=30.5%>${it.email}</td>
              <td width=10.5%>${it.user_id}</td>
              <td width=13%>${it.device_id }</td>
              </tr>
              </g:each>


              </table>
         </div>        
    </form>

这是一个如何出现的对话框的例子

enter image description here

非常感谢你们。如果需要,我可以为你们提供代码。

1 个答案:

答案 0 :(得分:1)

将.btn类用于您的tr并将您的用户名值包含在

<span class="username">${it.username}</span>

你的jquery应该

$(document).ready(function() {
  $(".btn tr").live("click", function{
    var name = $(this).find(".username").text();
    ...put your code here that will update your table...
  });
});

如果单击tr,它将找到具有“username”类的子项,并将为您获取数据。