mercredi 6 février 2019

link is not triggering ajax and my pop up window is not showing in rails

Trying to pop up a window in rails application. I used the jquery-rails gem, in link_to if I give show_new_path then it is showing the controller error in show if I pass show_new_path(format: :js), then it shows my modal as embedded code in next tab. I coded the use case in the following way.

  /*new.html.erb*/
    <%= link_to 'Link', teams_show_path, remote:true %>

    /*team_controller*/
    def show
        @user = User.all
        respond_to do |format|
          format.js 
        end
    end

    /*show.js.erb*/
    $("#modal-window").html("<%= escape_javascript(render 'show') %>");
    $("#modal-window").modal();

    /*_show.html.erb*/
    <div class="modal-header">
       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
       <h3 id="myModalLabel">Modal header</h3>
     </div>
     <div class="modal-body">
       **here comes whatever you want to show!**
     </div>
     <div class="modal-footer">
       <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
       <button class="btn btn-primary">Save changes</button>
     </div>

I am a beginner in rails please guide me with your valuable suggestions

Aucun commentaire:

Enregistrer un commentaire