Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:58:54+00:00 2026-05-26T22:58:54+00:00

I have tried to include a partial into a modal something similar to this

  • 0

I have tried to include a partial into a modal something similar to this Rails Admin
when you click on “create language”.

Now as I have not really found out how the code works there, I tried to do a mix between this Rails – AJAX a Modal Dialog? and something own.

The thing is, the partial gets rendered now into the modal. But when I hit “save”, the validation will go back to the “normal” create-new view and not show the validation errors directly within the modal.

  1. How can I show the validation errors in the popped up modal directly?

  2. When I save, I should somehow distinguish between a save from this modal and a normal save, as this partial will be called from somewhere else and would need to set the new created object directly as a new Object within a drop down. I guess i would need to distinguish from a response format and then use JS to set the new id to the DropDown id?

Here some code written so far. In the view where I include the partial it looks like this where i call another controller (as I am on a different controllers-new-view).

 $.get('<%= url_for :controller => 'customers', :action => 'new' %>',
            function(data) {
                $('#customer-modal').html(data);
            }
    );

Then the new in the “customres” controller distinguishs between the different request format and renders the different partial (in this case “_ajax_form.html.erb”):

if request.xhr?
  render "_ajax_form", :layout => false

In this partial, I use “simple_form_for @customer, :remote => true do |f]….”, so I guess at the end the submit should look different than standard, as this calls the normal “create” on the controller?

<div class="modal-footer">
    <%= f.button :submit, :class => 'btn primary' %>
    <a id='cancel-form' class= "btn small info">cancel</a>
  </div>

Thanks for any help which clarifies what I am doing wrong or how it should be done as my experience in Rails and JS/AXAX are not yet too experienced.. 😉

  • EDITED: I have now a version where in my special partial which is loaded within the modal, will call a seperate action called “new_from_sale” within the simple_form_for:

simple_form_for @customer, :url => url_for(:action => 'new_from_sale', :controller => 'customers') do |f|

Then in the controller, when the save is ok of this new object, I redirect to the first called view with the new id as a param which then fills the dropdown. In the else case, when the new object can not be saved, I need somehow to show the errors still in that modal.
So far both tries to either directly render the partial render :partial => "customers/ajax_form" or give back JS code render :js => "$('#sale_customer_id').val(#{@customer.id});" would not yet work.. but I’ll keep on trying my luck..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:58:54+00:00Added an answer on May 26, 2026 at 10:58 pm

    Here’s a basic example of how I’d do a modal form which I wrote in response to a similar question (Rails and modal jquery dialog form):

    https://github.com/ramblex/modal-form

    You need to add :remote => true to the form that gets loaded into the dialog. That will cause the JS format to be rendered from the create action. You can then handle the response in a create.js.erb.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have tried to create a generator like: #include <iostream> #include <iomanip> #include
File formats I would like to play include .wav, .mp3, .midi. I have tried
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
I have tried to find how to create DLL-s on linux using google, but
So I have tried GetType() but for some reason, It does include the namespace...
I have this, <script type=text/javascript> ... $(#img-clck).click(codeAddress); ... </script> <input type=image src=btn.png alt= id=img-clck
I need to echo entire content of included file. I have tried the below:
I have tried <ul id=contact_list> <li id=phone>Local 604-555-5555</li> <li id=i18l_phone>Toll-Free 1-800-555-5555</li> </ul> with #contact_list
I have tried what seems like everything - I've done similiar things many times
I have tried the following two statements: SELECT col FROM db.tbl WHERE col (LIKE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.