Atsuhiro Teshima
Atsuhiro Teshima

Reputation: 1508

Bootstrap modal show up twice

In my rails app, I'm using Twitter bootstrap.

Before, everything was working fine, but suddenly the modal start showing twice. I have no idea what's going on.. My code is like below.

devise/registrations/new.html.erb

<%= link_to "Terms of Service", terms_in_modal_path, {:class => "show-terms", :remote => true}

pages_controller

def terms_in_modal
  respond_to do |format|
    format.js
  end
end

terms_in_modal.js.erb

$("#signup-modal").html('<%= escape_javascript render(:partial => "terms_in_modal") %>');
$('#show-terms').modal('show');

_terms_in_modal.html.erb

<div id="show-terms" class="modal hide fade in">
...
</div>

After I click the link, two modals show up and the output html is like below.

<div id="signup-modal">
  <div id="show-terms" class="modal hide fade in" style="display: block; ">
    <div class="modal-header">
    ...
  </div>
</div>

<div class="modal-backdrop fade in"></div>
<div class="modal-backdrop fade in"></div>

<div id="show-terms" class="modal hide fade in" style="display: block; ">
    <div class="modal-header">
    ...
</div>

Edit1

In my staging app on Heroku, the modal work fine. Weird thing is, I didn't edit anything relate to modal and signup page after I push on heroku last time. I recently change the OS to Mountain Lion, so it may relate to the OS.

Edit2

I did "git push staging master" and tried if the modal will work fine, and it is working fine. Very weird..

Upvotes: 1

Views: 1463

Answers (1)

John
John

Reputation: 3296

It does this in your local environment most likely because your compiled assets that you need for Heroku are conflicting with the assets Rails includes on the fly when your in a development environment. To prevent this, you most likely need to just rm -rf public/assets to remove your precompiled assets. You should make sure to recompile them before every push to Heroku.

Upvotes: 2

Related Questions