使用jQuery酥料饼的CRUD我尝试添加的jQuery酥料饼到轨默认cruds而不是redireting到的意见和什么我做的是呈现形式,jquery的酥料饼:轨通过引导
<%= content_tag_for :tr, @order.order_items do |i| %>
<a class='btn btn-mini label-with-popover' id=<%=i.id%>><%= t('helpers.links.edit_html') %> </a>
<% end %>
<script type="text/javascript">
$(function() {
$('.label-with-popover').popover({
html : true,
content: "<%= escape_javascript(render :partial => 'form_item') %>" ,
placement: 'top'
});
});
</script>
,这里是我的form_item:
<%= simple_form_for :order_item, url: admin_shop_order_path, :html => { :class => 'form-horizontal' } do |f| %>
<div class='form-inputs'>
<%= f.input :item_id , :collection => @shop.products.collect{|b| b.variants}.flatten.map{|variant| ["#{variant_full_title(variant)}", variant.id]}%>
<%= f.input :quantity %>
</div>
<div class="form-actions">
<%= f.button :submit, :class => 'btn-primary' %>
<%= link_to t("helpers.links.cancel"), admin_shop_orders_path, :class => 'btn' %>
</div>
<% end %>
但问题出现在编辑按钮上。为了呈现编辑表单,我们需要我们想要编辑的对象(:order_item我的意思是)以及通过使用id来获取的方法,这就是为什么我设置了锚点标记ID。现在我们必须在popover函数中获取锚点ID,但$(this).id不起作用。任何建议?
是的,但仍有问题。我们不能在erb标签中使用这样的行:“<%=”+“escape_javascript ....(您的代码)”+“%>”。这是行不通的。我们在erb文件中。每个<%=翻译成ruby代码,如果我们使用“\ <\%\ =”,那么它不会作为ruby代码执行。 – Pooya
哪部分不起作用?你能否更新你的问题以包含来自erb的代码? – jibai31
整个提到的代码是在erb中。 – Pooya