jquery - Bootstrap modal edit form in Ruby on Rails -
i have _form , have display using bootstrap modal on same page.
i've admin.html code(where have modal code).
admin.html.erb
<div id="user_form" class="modal fade " tabindex="-1" role="dialog" style="display: none;"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-body "> <!-- want display _form.html.erb here edit details in modal when user clicks on link_to (which goes edit_reseller_path(reseller.id) path )--> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">close</button> </div> </div> </div> </div> <span style="float: right"> <%= link_to " <i class='fa fa-pencil'></i>".html_safe, edit_reseller_path(reseller.id) ,title: "edit profile", "data-toggle" => "modal", "data-dismiss=" => "modal" "data-target" => "#user_form" %> </span>
and form have edit bootstrap modal this.
_form.html.erb
<div id="user_form" > <!--[form:user]--> <div class="splitcontentleft"> <fieldset class="box tabular"> <legend><%=l(:label_information_plural)%></legend> <p><%= f.text_field :login, :required => true, :size => 25 %></p> <p><label for='reseller[firstname]'>name<span class="required"> *</span></label> <%= f.text_field :firstname, :required => true, :no_label => true %> </p> <p><%= f.text_field :mail, :required => true %></p> <p><%= f.text_field :contact_number%></p> <p><%= f.select :language, lang_options_for_select %></p> <!-- logic code goes here --> </div> <div class="splitcontentright"> <%= image_tag @reseller.avatar.url(:medium) unless @reseller.avatar.url(:medium) == "/avatars/medium/missing.png"%> </div> </div> <div style="clear:left;"></div> <!--[eoform:user]-->
currently, when click on link_to pencil icon redirecting new page edit. want edit on same page using modal. how can that? please me. tried keeping track of form id in modals , form not working.
your link tag missing data-target
attribute:
<%= link_to " <i class='fa fa-pencil'></i>".html_safe, edit_reseller_path(reseller.id) ,title: "edit profile", "data-toggle" => "modal", "data-dismiss=" => "modal", "data-target" => "#user_form"%>
rails 4:
<%= link_to " <i class='fa fa-pencil'></i>".html_safe, edit_reseller_path(reseller.id), title: "edit profile", data: { toggle: 'modal', dismiss: 'modal', target: '#user_form'} %>
admin.html.erb
<div id="user_form" class="modal fade " tabindex="-1" role="dialog" style="display: none;"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-body "> <%= render partial: 'form' %> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">close</button> </div> </div> </div> </div> <span style="float: right"> <%= link_to " <i class='fa fa-pencil'></i>".html_safe, edit_reseller_path(reseller.id), title: "edit profile", data: { toggle: 'modal', dismiss: 'modal', target: '#user_form'} %> </span>
_form.html.erb
<div id="some_id" > <div class="splitcontentleft"> <fieldset class="box tabular"> <legend><%=l(:label_information_plural)%></legend> <p><%= f.text_field :login, :required => true, :size => 25 %></p> <p><label for='reseller[firstname]'>name<span class="required"> *</span></label> <%= f.text_field :firstname, :required => true, :no_label => true %> </p> <p><%= f.text_field :mail, :required => true %></p> <p><%= f.text_field :contact_number%></p> <p><%= f.select :language, lang_options_for_select %></p> </fieldset> </div> <div class="splitcontentright"> <%= image_tag @reseller.avatar.url(:medium) unless @reseller.avatar.url(:medium) == "/avatars/medium/missing.png"%> </div> </div> <div style="clear:left;"></div>
friendly advice: try not use inline style.
Comments
Post a Comment