javascript - Rails; display modal after an action and page reload -
i have following code...
controller
... session[:registration_modal] = true redirect_to(event_path(@event))
_main.html.erb
... <!-- modal --> <div class="modal fade" id="registration-modal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">registration notice!</h4> </div> <div class="modal-body"> thank registering event. not receive $200 , not pass go! </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> <% if session[:registration_modal] == true %> <%= render :partial => 'registration_modal'%> <% session[:registration_modal] = false %> <% end %>
_registration_modal.html.erb
<script class="code" type="text/javascript"> $('#registration-modal').modal('show'); </script>
this code works. after controller action runs, modal popup. move modal code out of _main partial , _registration_modal partial. when that, modal broken. seems javascript looking #registration-modal
in _main. how can tell in _registration_modal?
edit
here make work: https://gist.github.com/marklocklear/24f92405b7e9d1f61de1
Comments
Post a Comment