Ruby on rails Rails:如何在页面上重新呈现局部视图?
我有一个带有部分视图的网页,它有一个按钮并显示一些信息。当用户单击此部分视图中的按钮时,我需要能够从调用的操作中的控制器更新该部分视图。具体来说,我想更新一个字符串。这是到目前为止我的代码,但它不起作用 局部视图(_printLabel.rhtml)Ruby on rails Rails:如何在页面上重新呈现局部视图?,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我有一个带有部分视图的网页,它有一个按钮并显示一些信息。当用户单击此部分视图中的按钮时,我需要能够从调用的操作中的控制器更新该部分视图。具体来说,我想更新一个字符串。这是到目前为止我的代码,但它不起作用 局部视图(_printLabel.rhtml) 我没有看到任何错误,但是errorMessage字符串没有从“HI”更新为“Bye”。您不能从控制器调用render partial。相反,渲染模板并使用实例变量将不同的错误消息传递给分部 <% if @printAsinEnabled %&
我没有看到任何错误,但是errorMessage字符串没有从“HI”更新为“Bye”。您不能从控制器调用render partial。相反,渲染模板并使用实例变量将不同的错误消息传递给分部
<% if @printAsinEnabled %>
<%= check_box_tag(:needPrint, :needPrint, false,
:onchange => "if (this.checked) $('printLabelAction').show(); else $('printLabelAction').hide();") %>
<%=_('Need to print label?')%><br /><br />
<div id="printLabelAction" class="action" style="display:none;">
<% onPrintLabelClick = generateAjaxRequest(
{:controller => @controller.controller_name,
:action => 'processPrintLabelRequest',
:creturnWipItemId => creturnWipItemId,
:barcode => collectedItemData.fnsku,
:title => asinInfo["title"]},
["parameters: Form.serializeElements([$('printerAddress'),$('printerRemote_true'),$('printerRemote_false')])"]) %>
<%=_('Printing')%>: <%= collectedItemData.fnsku %> <br /> <br />
<%= radio_button_tag(:printerRemote, :false, !session[:printRemote]) %>
<label for="printerRemote_false"><%=_('Local Printer')%></label> <br />
<%= radio_button_tag(:printerRemote, :true, session[:printRemote]) %>
<label for="printerRemote_true"><%=_('Remote Printer')%> - <%=_('Printer Address')%>:</label>
<%= text_field_tag(:printerAddress, session[:printerAddress],
:onchange => onPrintLabelClick,
:onclick => "$('printerRemote_true').checked = true")%> <br />
<div style="text-align:right;">
<%= button_to_function(_("Print Label"), onPrintLabelClick) %>
</div>
<%=_('Error?')%>: <%= errorMessage %> <br /> <br />
</div>
<div id="Block_asinSummary" class="block">
...
...
<td height="200px" width ="70%">
<%= link_to asinInfo["title"], asinInfo["link"], :target => "_blank" %><br/><br/>
<% if !asinInfo["clothingSize"].nil? %>
<b><%= _('Size')%>: </b> <%= asinInfo["clothingSize"]%><br>
<% end %>
<font size='1'>
<% sku = collectedItemData.displaySku %>
<% if sku != collectedItemData.asin%>
<b>SKU:</b> <%= sku %><br>
<% else %>
<b>ASIN:</b> <%= collectedItemData.asin %>
<% end %>
<%= render(:partial => 'printLabel', :locals => { :creturnWipItemId => creturnWipItemId, :collectedItemData => collectedItemData, :asinInfo => asinInfo, :errorMessage => "HI" })%>
</font>
</td>
</tr>
</table>
...
...
<% end %>
render(:partial => 'printLabel', :layout => false, :locals => { :creturnWipItemId => creturnWipItemId, :collectedItemData => @collectedItemData, :asinInfo => asinInfo, :errorMessage => "Bye" })