我正在使用 JQuery Mobile 进行标记,我注意到 application_helper.rb 中的 link_to_add_fields 不会将渲染转换为 jquery mobile 样式。这是有道理的,JQuery Mobile 在将其呈现给浏览器之前会使用其框架标记事物。但是,有没有办法解决这个问题并将其呈现在服务器端?
代码:-
_certification.html.erb
<fieldset>
<%= f.input :certification,:input_html=>{:class=>"string optional ui-input-text ui-body-d"} %>
<%= link_to('#', class: "label label-inverse") do%>Remove<i class="remove-icon"></i><% end %>
</fieldset>
_form.html.erb
<%= f.simple_fields_for :certifications do |ed|%>
<%= render "certifications", f: ed %>
<% end %>
<%= link_to_add_fields "Add Achievement", f, :certifications,'user' %>
application_helper.rb
def link_to_add_fields(name, f, association,controller= "")
new_object = f.object.send(association).klass.new
id = new_object.object_id
fields = f.simple_fields_for(association, new_object, child_index: id) do |builder|
render(controller.to_s + '/' + association.to_s, f: builder)
end
link_to(name, '#', class: "btn btn-inverse", data: {id: id, fields: fields.gsub("\n", "")})
end