javascript 正则

本文介绍了一个产品管理页面的实现方式,该页面展示了产品的各项属性,如ID、名称、促销信息等,并提供了分页导航功能及产品操作选项。通过JavaScript增强了页面交互性,实现了基于AJAX的异步更新。
<table>
  <tr>
    <th>pic</th>
    <th>Id</th>
    <th>Name</th>
    <th>P1</th>
    <th>P2</th>
    <th>P3</th>
    <th>P4</th>
    <th>Promotion</th>
    <th>New</th>
    <th>Score</th>
    <th>S1</th>
    <th>Description</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>
<% @products.each do |product| %>
  <tr>
    <td><%=image_tag product.i1.url(:thumb)%></td>
    <td><%= product.id %></td>
    <td><%= product.name %></td>
    <td><%= product.p1 %></td>
    <td><%= product.p2 %></td>
    <td><%= product.p3 %></td>
    <td><%= product.p4 %></td>
    <td><%= product.promotion %></td>
    <td><%= product.new %></td>
    <td><%= product.score %></td>
    <td><%= product.s1 %></td>
    <td><%= product.description %></td>
    <td><%= link_to 'Show', admin_product_path(product) %></td>
    <td><%= link_to 'Edit', edit_admin_product_path(product) %></td>
    <td><%= link_to 'Destroy', admin_product_path(product), :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>
<input type="text" id="page" name="page" value="<%=@products.current_page%>" />
<input type="text" id="source" name="source" value="" />
<%=will_paginate @products%>
<script type="text/javascript">
      
      //$('.pagination a').attr('data-remote', 'true');
      $('.pagination a').click(function(){
        alert($(this).attr("href"));
        var result="";
        var subject=$(this).attr("href");//  /admin/products/search?page=9
        var myregexp = /\/admin\/products\/search\?page=(\d+)/;
        var match = myregexp.exec(subject);
        if (match != null) {
                result = match[1];
        }
        alert(result);
        $("input[name='page']").val(result);
        $("#source").val("");
        alert($("#form2").serialize());
        $.post($("#form2").attr("action")+".js",$("#form2").serialize(),null,"script");
        return false;
        
        });
      
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值