0

当我触摸表格行时,我想执行导航到其他屏幕。为此,我执行了以下操作:

<table>
<tr><a href="<%= url_for :controller => :Products %>"></a>
<td width="80"><img src="http://images.bizrate.com/resize?sq=60&uid=2605377575" width="80px"></img></td>
<td>
<table>
    <tr>
        <td width="260"><label for="label1">GPS Navigation System-$68.00</label></td>
    </tr>
        <tr>
<td width="260"><label for="label2">TomTom 3.5 One 125</label></td>  
        </tr>
        </table>
        </td>
        </tr>
</table>  

但是什么也没发生。我也尝试<a href="<%= url_for :controller => :Products %>"></a>td中申请。仍然没有成功。最后我尝试了无序列表。仍然没有发生任何事情。
我们如何在表格行触摸上导航到其他屏幕?

4

1 回答 1

1

你需要在你的锚标签中指定一个动作,而不仅仅是一个控制器。您可以尝试以下方法:

<table>
   <tr onclick="rowClick();">
     <td width="80"><img src="http://images.bizrate.com/resize?sq=60&uid=2605377575" width="80px"></img></td>
     <td>
       <table>
         <tr>
           <td width="260"><label for="label1">GPS Navigation System-$68.00</label></td>
         </tr>
         <tr>
           <td width="260"><label for="label2">TomTom 3.5 One 125</label></td>  
         </tr>
       </table>
     </td>
   </tr>
</table>

<script type="text/javascript">
  function rowClick() {
    window.location = "<%= url_for :controller => :Products, :action => :show, :params => { :item_id => 1234 } %>";
  }
</script>
于 2011-11-08T14:40:47.513 回答