Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal error rerenders whole page beneath modal (same behavior if class = modal fade) #28

Open
Jacubeit opened this issue Dec 10, 2012 · 3 comments

Comments

@Jacubeit
Copy link

Hi,
thanks for the great work!
The Modal error Handling seems to have an issue. If I just press "Request Invitation" without providing an email, I get an error inside the modal. This is defined by

<div id =" request-invite" class="modal" style="display: <%= @user.errors.any? ? 'block' : 'none'; %>

So far this is great!

I now added some pictures to the page (beneath the modal) wrapped in a seperate div, but on error it will render the whole page again. see attached image.

Seems like the same behavior when I set ...class "modal fade" (I would love to have some transition).

I tried for the last 5 Days to rewrite the modal dialog to use Rails build in ajax (remote => true). But I just could not get it to work.

Do you have any suggestion, how I can fix the error handling to only prompt the error and not misbehave like in the screenshot?

Thank you so much!
joh
Bildschirmfoto 2012-12-10 um 11.08.16.png

@Jacubeit
Copy link
Author

Ok, I think I have a fix, please try and verify (I am new to programming, so please consider this a hack)

RegistrationsController:

def create
build_resource
  if...
    if...
    else...
    end
    elsif resource.errors.any?
        (render(:partial => 'modal', :layout => false) && return)  if request.xhr?
    else...
  end
end

views/devise/registrations/new:

<div id="request-invite" class="<%= @user.errors.any? ? 'modal' : 'modal hide'%>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

I still believe that rerendering the modal on an ajax request seems not the right way to me?! But as stated before, I tried remote => true and could not get it to work.

Thank you

@allyf
Copy link

allyf commented May 22, 2013

Add style to

in registrations/new.html.erb as following:
div class="modal-body" style="margin-bottom: 120px; overflow: visible"
It changes dialog's size and fixes rendering issue.

@mickume
Copy link

mickume commented Jun 7, 2013

I ran into the same problem; I currently use the first suggestion but would like to get errors messages back if possible. The second suggestion did not change anything for me ...

I will have a look once 've got time how to fix this ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants