处理Rails 3中的js.erb文件 - 续集

时间:2011-12-16 18:56:36

标签: javascript ruby-on-rails-3 jquery unobtrusive-javascript

我终于将Rails应用程序CRUD转换为AJAX,因为只有一个页面刷新和所有控制器操作:创建,删除和编辑/更新由AJAX驱动。真的很整洁。有两个残留问题:

  • 我卡在屏幕顶部的更新模式_form partial,因为我无法更改提交按钮的模式,我希望它在除Edit之外的每个操作后都是Create。我该怎么做 - 是通过使用JQuery或某些控制器操作更改屏幕。

  • 第二个问题看起来简单得多。当我将所需字段留空时,应用程序会抛出错误条件。在相关的js.erb文件中,create.js,erb和update.js.erb采用了错误路径,但屏幕上没有出现错误。

我列出了以下相关文件 - 客户控制器,以及客户视图下的各种html.erb和js.erb文件。

客户控制人:

 class CustomersController < ApplicationController

  before_filter :load

  def load
    @customers = Customer.all
    @customer  = Customer.new
  end

  # Display composite form used for AJAX operations.

  def index   
  end




  # This method implements customer create action for AJAX request.

  def create  
    @customer = Customer.new(params[:customer])
    if @customer.save
      flash[:notice] = "Customer Record Created."
      @customers = Customer.all
      respond_to do |format|
        format.js
      end
    end 

  end 


  # This method get customer for editing using AJAX.

  def edit
    @customer = Customer.find(params[:id])

    respond_to do |format|
      format.js
    end
  end

  # This method implements customer update from AJAX form.

  def update
    @customer = Customer.find(params[:id])
    if @customer.update_attributes(params[:customer])
      flash[:notice] = "Customer Record Updated."
      @customers = Customer.all
      respond_to do |format|
        format.js
      end 
    end
  end  

  # This method implements customer delete from AJAX form.
  def destroy
    @customer = Customer.find(params[:id])
    @customer.destroy
    flash[:notice] = "Customer Record Deleted"
    @customers = Customer.all
    respond_to do |format|
      format.js
    end

  end

  # This method lists all customers on file. 

  def getcustsjson
    render :json => @customers
  end

  # This method lists all the books purchased by a particular customer.

  def getbooksjson

    @customer = Customer.find(params[:id]) 
    @order = @customer.order
    @orderitems = Orderitem.find_all_by_order_id(@order)
    @book = Book.find_all_by_id(@orderitems)

    render :json => @book 

  end 

end

索引表:

<div id="customer_form"><%= render 'form' %></div>
<div id="customers_list"><%= render 'customers' %></div>

_Form Partial with submit button:

<%= form_for(@customer, :remote => true) do |f| %>


  <div id="customer_errors" style="display:none"></div>

  <div class="field">
    <%= f.label :firstname %>
    <%= f.text_field :firstname %>
    <%= f.label :lastname %>
    <%= f.text_field :lastname %>
  </div>
  <div class="field">
    <%= f.label :email %>
    <%= f.text_field :email %>
    <%= f.label :phone %>
    <%= f.text_field :phone %>
  </div>
  <div class="field">
    <%= f.label :password %>
    <%= f.text_field :password %>
    <%= f.label :address_id %>
    <%= f.text_field :address_id %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

_Customers Partial:

<table>
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Email</th>
    <th>Phone</th>
    <th>Password</th>
    <th>Address</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @customers.each do |customer| %>
  <tr>
    <td><%= customer.firstname %></td>
    <td><%= customer.lastname %></td>
    <td><%= customer.email %></td>
    <td><%= customer.phone %></td>
    <td><%= customer.password %></td>
    <td><%= customer.address_id %></td>
    <td><%= link_to 'Edit', edit_customer_path(customer), :remote => true %></td>
    <td><%= link_to 'Destroy', customer, :remote => true, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

包含错误代码的Create.js.erb文件:

<% if @customer.errors.any? -%> 

   /* Hide the Flash Notice div */
   $("#flash_notice").hide(300);

   /* Update the html of the div customer_errors with the new one */
   $("#customer_errors").html("<% @customer.errors.full_messages.each do |msg| %>
                              <li><%= escape_javascript ( msg ) %></li> 
                              <% end %>");

   /* Show the div customer_errors */
   $("#customer_errors").show(300);

<% else -%>

   /* Hide the div customer_errors */
   $("#customer_errors").hide(300);

   /* Update the html of the div flash_notice with the new one */
   $("#flash_notice").html("<%= flash[:notice] %>");

   /* Show the flash_notice div */
   $("#flash_notice").show(300);

   /* Clear the entire form */
   $(":input:not(input[type=submit])").val("");

   /* Replace the html of the div customers_list with the updated new one */
   $("#customers_list").html("<%=  escape_javascript render('customers') %>");

   <% end %>

Edit.js.erb代码:

$("#customer_form").html("<%= escape_javascript render('form') %>");

Update.js.erb代码包含错误代码:

<% if @customer.errors.any? -%>
   $("#flash_notice").hide(300);
   $("#customer_errors").html("<% @customer.errors.full_messages.each do |msg| %>
                              <li><%= escape_javascript ( msg ) %></li> 
                              <% end %>");
   $("#customer_errors").show(300);
<% else -%>
   $("#customer_errors").hide(300);
   $("#flash_notice").html("<%= flash[:notice] %>");
   $(":input:not(input[type=submit])").val("");
   $("#customer_form").html("<%= escape_javascript render('form') %>");
   $("#customers_list").html("<%= escape_javascript render('customers') %>");
<% end %>

最后是Destroy.js.erb,我需要在执行后重置为创建模式:

$("#customer_errors").hide(300);
$("#flash_notice").html("<%= flash[:notice] %>");
$("#flash_notice").show(300);
$("#customers_list").html("<%= escape_javascript render('customers') %>");



$("#customer_form").html("<%= escape_javascript render('form') %>");

如果还需要其他任何东西 - 请询问。

编辑:

我现在还有一个问题,即编辑操作无法正常工作。查看日志事务是否正确发布,但响应使表单顶部保持不变,而不是显示要更新的记录的详细信息。我已粘贴最新的控制器代码。

编辑II:

现在问题似乎是没有处理customer_errors和customer_form div的DOM更新。相比之下,对customer_list div的所有更新都得到了很好的处理。我在下面列出了两种类型的消息的响应内容,以及浏览器中的源列表,显示了很多div。

浏览器的来源是:

<!DOCTYPE html>
<html>
<head>
  <title>OnlineBookStore</title>
  <link href="/stylesheets/scaffold.css?1323327452" media="screen" rel="stylesheet" type="text/css" />
  <script src="/javascripts/jquery.js?1323855673" type="text/javascript"></script>
<script src="/javascripts/jquery-ui.js?1323855673" type="text/javascript"></script>
<script src="/javascripts/jquery_ujs.js?1323855673" type="text/javascript"></script>
<script src="/javascripts/application.js?1323327452" type="text/javascript"></script>

  <meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="CROTodz0FR1ZJpl+Lp4xL0fh6Dx8ydu6Ge5OBSV23g4="/>
</head>
<body>
  <div id="container">
    <div id="flash_notice" style="display:none"></div

<div id="customer_form">


<form accept-charset="UTF-8" action="/customers" class="new_customer" data-remote="true" id="new_customer" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="CROTodz0FR1ZJpl+Lp4xL0fh6Dx8ydu6Ge5OBSV23g4=" /></div>

  <div id="customer_errors" style="display:none"></div>

  <div class="field">

    <label for="customer_firstname">Firstname</label>
    <input id="customer_firstname" name="customer[firstname]" size="30" type="text" />
    <label for="customer_Lastname">Lastname</label>
    <input id="customer_lastname" name="customer[lastname]" size="30" type="text" />
  </div>
  <div class="field">
    <label for="customer_email">Email</label>

    <input id="customer_email" name="customer[email]" size="30" type="text" />
    <label for="customer_phone">Phone</label>
    <input id="customer_phone" name="customer[phone]" size="30" type="text" />
  </div>
  <div class="field">
    <label for="customer_password">Password</label>
    <input id="customer_password" name="customer[password]" size="30" type="text" />
    <label for="customer_address_id">Address</label>

    <input id="customer_address_id" name="customer[address_id]" size="30" type="text" />
  </div>
  <div class="actions">
    <input id="customer_submit" name="commit" type="submit" value="Create Customer" />
  </div>
</form></div>
<div id="customers_list">
<table>
  <tr>
    <th>Firstname</th>

    <th>Lastname</th>
    <th>Email</th>
    <th>Phone</th>
    <th>Password</th>
    <th>Address</th>
    <th></th>

    <th></th>
    <th></th>
  </tr>

  <tr>
    <td>Jonathan </td>
    <td>McCarthy</td>
    <td>jonathan.mccarthy@ncirl.ie</td>

    <td>083 4342009</td>
    <td>letmeinsoon</td>
    <td>1</td>
    <td><a href="/customers/1/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/1" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>

  <tr>
    <td>Joseph</td>
    <td>McGouran</td>
    <td>joe_mcgouran@yahoo.ie</td>
    <td>086 2210662</td>
    <td>accesssought</td>

    <td>1</td>
    <td><a href="/customers/3/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/3" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>
  <tr>
    <td>Marie</td>
    <td>McGouran</td>

    <td>mariemcgouran@yahoo.co.uk</td>
    <td>2988858</td>
    <td>dontmesswithme</td>
    <td>1</td>
    <td><a href="/customers/4/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/4" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>

  </tr>
  <tr>
    <td>Stephen </td>
    <td>McGouran</td>
    <td>stephenmcgouran@gmail.com</td>
    <td>2988858</td>
    <td>whogoesthere</td>

    <td>1</td>
    <td><a href="/customers/7/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/7" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>
  <tr>
    <td>Cathy </td>
    <td>McGouran</td>

    <td>cathymcgouran@gmail.com</td>
    <td>2988858</td>
    <td>openthedoor</td>
    <td>1</td>
    <td><a href="/customers/8/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/8" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>

  </tr>
  <tr>
    <td>Peter </td>
    <td>McGouran</td>
    <td>petermcgouran@gmail.com</td>
    <td>74931548</td>
    <td>open sesame</td>

    <td>1</td>
    <td><a href="/customers/9/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/9" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>
  <tr>
    <td>Gary</td>
    <td>McGouran</td>

    <td>garymcgouran@gmail.com</td>
    <td>5566779824</td>
    <td>pilotgogo</td>
    <td>1</td>
    <td><a href="/customers/11/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/11" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>

  </tr>
  <tr>
    <td>Matthew</td>
    <td>Busby</td>
    <td>mattbusby@gmail.com</td>
    <td>76588888</td>
    <td>babesteam</td>

    <td>1</td>
    <td><a href="/customers/15/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/15" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>
  <tr>
    <td>John </td>
    <td>Beales</td>

    <td>johnbeales@yahoo.com</td>
    <td>9988664433</td>
    <td>russiantripper</td>
    <td>1</td>
    <td><a href="/customers/20/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/20" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>

  </tr>
  <tr>
    <td>Brian</td>
    <td>Wade</td>
    <td>bbwade@gmail.com</td>
    <td>9999998888</td>
    <td>wadeoff</td>

    <td>1</td>
    <td><a href="/customers/30/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/30" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>
  <tr>
    <td>Yasser</td>
    <td>Arafat</td>

    <td>yasser@Gmail.com</td>
    <td>9999999-999</td>
    <td>speaksoftly my friend</td>
    <td>1</td>
    <td><a href="/customers/31/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/31" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>

  </tr>
  <tr>
    <td>MIchael </td>
    <td>Sweeney</td>
    <td>mick@ntma.com</td>
    <td>456278</td>
    <td>mickn</td>

    <td>2</td>
    <td><a href="/customers/35/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/35" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>
  <tr>
    <td>MIchael</td>
    <td>Semple</td>

    <td>mibksemp@gmail.com</td>
    <td>0044897345</td>
    <td>micko</td>
    <td>1</td>
    <td><a href="/customers/36/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/36" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>

  </tr>
  <tr>
    <td>Harry</td>
    <td>Potter</td>
    <td>harrypot@gmail.com</td>
    <td>086332123</td>
    <td>wizard</td>

    <td>1</td>
    <td><a href="/customers/39/edit" data-remote="true">Edit</a></td>
    <td><a href="/customers/39" data-confirm="Are you sure?" data-method="delete" data-remote="true" rel="nofollow">Destroy</a></td>
  </tr>
</table>


</div>



  </div>
</body>
</html

从服务器发送的错误消息的JS如下所示。 customer_errors div没有任何反应:

   /* Hide the Flash Notice div */
   /* Update the html of the div customer_errors with the new one */
   /* Show the div customer_errors */

   $("#flash_notice").hide(300);
   $("#customer_errors").html(
                            <li>Phone can\'t be blank</li>

                            <li>Password can\'t be blank</li>

                            <li>Address can\'t be blank</li>
                            );
   $("#customer_errors").show(300);

从服务器发送的用于编辑操作的JS如下所示。基本上我似乎无法在firebug中找到Div更新字符串中是否存在某种错误:

$("#customer_form").html("\n<form accept-charset=\"UTF-8\" action=\"/customers/4\" class=\"edit_customer\" data-remote=\"true\" id=\"edit_customer_4\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input name=\"_method\" type=\"hidden\" value=\"put\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"mOAikAY8A22vPmNYzLWWm64lPU22imzIA/jOcXQVhAw=\" /><\/div>\n\n  <div id=\"customer_errors\" style=\"display:none\"><\/div>\n\n  <div class=\"field\">\n    <label for=\"customer_firstname\">Firstname<\/label>\n    <input id=\"customer_firstname\" name=\"customer[firstname]\" size=\"30\" type=\"text\" value=\"Marie\" />\n    <label for=\"customer_Lastname\">Lastname<\/label>\n    <input id=\"customer_lastname\" name=\"customer[lastname]\" size=\"30\" type=\"text\" value=\"McGouran\" />\n  <\/div>\n  <div class=\"field\">\n    <label for=\"customer_email\">Email<\/label>\n    <input id=\"customer_email\" name=\"customer[email]\" size=\"30\" type=\"text\" value=\"mariemcgouran@yahoo.co.uk\" />\n    <label for=\"customer_phone\">Phone<\/label>\n    <input id=\"customer_phone\" name=\"customer[phone]\" size=\"30\" type=\"text\" value=\"2988858\" />\n  <\/div>\n  <div class=\"field\">\n    <label for=\"customer_password\">Password<\/label>\n    <input id=\"customer_password\" name=\"customer[password]\" size=\"30\" type=\"text\" value=\"dontmesswithme\" />\n    <label for=\"customer_address_id\">Address<\/label>\n    <input id=\"customer_address_id\" name=\"customer[address_id]\" size=\"30\" type=\"text\" value=\"1\" />\n  <\/div>\n  <div class=\"actions\">\n    <input id=\"customer_submit\" name=\"commit\" type=\"submit\" value=\"Update Customer\" />\n  <\/div>\n<\/form>");

这是在成功创建新记录后生成的JS。它有效:

   /* Hide the div customer_errors */
   /* Update the html of the div flash_notice with the new one */
   /* Clear the form */
   /* Replace the html of the div customers_list with the updated one */

   $("#customer_errors").hide(300);  
   $("#flash_notice").html("Customer Record Created.");   
   $("#flash_notice").show(300);   
   $(":input:not(input[type=submit])").val("");  
   $("#customers_list").html("\n<table>\n  <tr>\n    <th>Firstname<\/th>\n    <th>Lastname<\/th>\n    <th>Email<\/th>\n    <th>Phone<\/th>\n    <th>Password<\/th>\n    <th>Address<\/th>\n    <th><\/th>\n    <th><\/th>\n    <th><\/th>\n  <\/tr>\n\n  <tr>\n    <td>Jonathan <\/td>\n    <td>McCarthy<\/td>\n    <td>jonathan.mccarthy@ncirl.ie<\/td>\n    <td>083 4342009<\/td>\n    <td>letmeinsoon<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/1/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/1\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Joseph<\/td>\n    <td>McGouran<\/td>\n    <td>joe_mcgouran@yahoo.ie<\/td>\n    <td>086 2210662<\/td>\n    <td>accesssought<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/3/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/3\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Marie<\/td>\n    <td>McGouran<\/td>\n    <td>mariemcgouran@yahoo.co.uk<\/td>\n    <td>2988858<\/td>\n    <td>dontmesswithme<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/4/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/4\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Stephen <\/td>\n    <td>McGouran<\/td>\n    <td>stephenmcgouran@gmail.com<\/td>\n    <td>2988858<\/td>\n    <td>whogoesthere<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/7/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/7\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Cathy <\/td>\n    <td>McGouran<\/td>\n    <td>cathymcgouran@gmail.com<\/td>\n    <td>2988858<\/td>\n    <td>openthedoor<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/8/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/8\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Peter <\/td>\n    <td>McGouran<\/td>\n    <td>petermcgouran@gmail.com<\/td>\n    <td>74931548<\/td>\n    <td>open sesame<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/9/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/9\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Gary<\/td>\n    <td>McGouran<\/td>\n    <td>garymcgouran@gmail.com<\/td>\n    <td>5566779824<\/td>\n    <td>pilotgogo<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/11/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/11\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>John <\/td>\n    <td>Beales<\/td>\n    <td>johnbeales@yahoo.com<\/td>\n    <td>9988664433<\/td>\n    <td>russiantripper<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/20/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/20\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>MIchael <\/td>\n    <td>Sweeney<\/td>\n    <td>mick@ntma.com<\/td>\n    <td>456278<\/td>\n    <td>mickn<\/td>\n    <td>2<\/td>\n    <td><a href=\"/customers/35/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/35\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>bbbbbb<\/td>\n    <td>ddddddddd<\/td>\n    <td>gggggggg<\/td>\n    <td>9999999999<\/td>\n    <td>enterin<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/48/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/48\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n<\/table>\n\n\n");

这是成功删除后生成的JS。它类似于创建成功记录后的操作。

/* hide customer_errors div */
/* show flash notice */
/* send script to update customers_list div with new customers list */

$("#customer_errors").hide(300);
$("#flash_notice").html("Customer Record Deleted");
$("#flash_notice").show(300);
$("#customers_list").html("\n<table>\n  <tr>\n    <th>Firstname<\/th>\n    <th>Lastname<\/th>\n    <th>Email<\/th>\n    <th>Phone<\/th>\n    <th>Password<\/th>\n    <th>Address<\/th>\n    <th><\/th>\n    <th><\/th>\n    <th><\/th>\n  <\/tr>\n\n  <tr>\n    <td>Jonathan <\/td>\n    <td>McCarthy<\/td>\n    <td>jonathan.mccarthy@ncirl.ie<\/td>\n    <td>083 4342009<\/td>\n    <td>letmeinsoon<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/1/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/1\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Joseph<\/td>\n    <td>McGouran<\/td>\n    <td>joe_mcgouran@yahoo.ie<\/td>\n    <td>086 2210662<\/td>\n    <td>accesssought<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/3/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/3\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Marie<\/td>\n    <td>McGouran<\/td>\n    <td>mariemcgouran@yahoo.co.uk<\/td>\n    <td>2988858<\/td>\n    <td>dontmesswithme<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/4/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/4\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Stephen <\/td>\n    <td>McGouran<\/td>\n    <td>stephenmcgouran@gmail.com<\/td>\n    <td>2988858<\/td>\n    <td>whogoesthere<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/7/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/7\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Cathy <\/td>\n    <td>McGouran<\/td>\n    <td>cathymcgouran@gmail.com<\/td>\n    <td>2988858<\/td>\n    <td>openthedoor<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/8/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/8\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Peter <\/td>\n    <td>McGouran<\/td>\n    <td>petermcgouran@gmail.com<\/td>\n    <td>74931548<\/td>\n    <td>open sesame<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/9/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/9\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>Gary<\/td>\n    <td>McGouran<\/td>\n    <td>garymcgouran@gmail.com<\/td>\n    <td>5566779824<\/td>\n    <td>pilotgogo<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/11/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/11\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>John <\/td>\n    <td>Beales<\/td>\n    <td>johnbeales@yahoo.com<\/td>\n    <td>9988664433<\/td>\n    <td>russiantripper<\/td>\n    <td>1<\/td>\n    <td><a href=\"/customers/20/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/20\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n  <tr>\n    <td>MIchael <\/td>\n    <td>Sweeney<\/td>\n    <td>mick@ntma.com<\/td>\n    <td>456278<\/td>\n    <td>mickn<\/td>\n    <td>2<\/td>\n    <td><a href=\"/customers/35/edit\" data-remote=\"true\">Edit<\/a><\/td>\n    <td><a href=\"/customers/35\" data-confirm=\"Are you sure?\" data-method=\"delete\" data-remote=\"true\" rel=\"nofollow\">Destroy<\/a><\/td>\n  <\/tr>\n<\/table>\n\n\n");

从上面可以清楚地看到,“customers_list”div总是更新没有问题,而“customer_form”和“customer_errors”根本没有。

0 个答案:

没有答案