Ruby on Rails - Partial not rendering link on creation











up vote
0
down vote

favorite












Yo guys, I'm learning Rails and having a interesing problem



I have a this partial.



_access_point.html.erb



<div class="card">
<div class="card-body">
<div class="card-title">
<h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3>
</div>
<div class="card-text">
<p><strong>Manufacturer: </strong><%= access_point.manufacturer %></p>
<p><strong>Serial number: </strong><%= access_point.serial_number %></p>
<p><strong>USER: </strong><%= access_point.user %></p>
<p><strong>PASSWORD: </strong><%= access_point.password %></p>
</div>
</div>
</div>


create.js.erb



$('#access-points-cards').append('<%= j render partial: 'access_point', locals: { access_point: @access_point }, layout: 'layouts/col-md-4' %>')
$('#new-access-point').modal('hide')


and I´m using a modal form, with remote: true to create it, after inserting the EDIT button don´t show up in the browser, but show in the dev tools, if I hit F5 it shows everything ok, don´t know if its a turbolinks problem or something like that.



Can you help me?










share|improve this question






















  • So the _access_point partial isn't rendered at all or there are some problems with it after it got rendered?
    – bernstein7
    Nov 8 at 16:03










  • it is rendered normally. <h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3> in this part of the partial, the link_to_unless_current works normally, but the fa_icon doesn´t show
    – Joz
    Nov 9 at 10:13

















up vote
0
down vote

favorite












Yo guys, I'm learning Rails and having a interesing problem



I have a this partial.



_access_point.html.erb



<div class="card">
<div class="card-body">
<div class="card-title">
<h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3>
</div>
<div class="card-text">
<p><strong>Manufacturer: </strong><%= access_point.manufacturer %></p>
<p><strong>Serial number: </strong><%= access_point.serial_number %></p>
<p><strong>USER: </strong><%= access_point.user %></p>
<p><strong>PASSWORD: </strong><%= access_point.password %></p>
</div>
</div>
</div>


create.js.erb



$('#access-points-cards').append('<%= j render partial: 'access_point', locals: { access_point: @access_point }, layout: 'layouts/col-md-4' %>')
$('#new-access-point').modal('hide')


and I´m using a modal form, with remote: true to create it, after inserting the EDIT button don´t show up in the browser, but show in the dev tools, if I hit F5 it shows everything ok, don´t know if its a turbolinks problem or something like that.



Can you help me?










share|improve this question






















  • So the _access_point partial isn't rendered at all or there are some problems with it after it got rendered?
    – bernstein7
    Nov 8 at 16:03










  • it is rendered normally. <h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3> in this part of the partial, the link_to_unless_current works normally, but the fa_icon doesn´t show
    – Joz
    Nov 9 at 10:13















up vote
0
down vote

favorite









up vote
0
down vote

favorite











Yo guys, I'm learning Rails and having a interesing problem



I have a this partial.



_access_point.html.erb



<div class="card">
<div class="card-body">
<div class="card-title">
<h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3>
</div>
<div class="card-text">
<p><strong>Manufacturer: </strong><%= access_point.manufacturer %></p>
<p><strong>Serial number: </strong><%= access_point.serial_number %></p>
<p><strong>USER: </strong><%= access_point.user %></p>
<p><strong>PASSWORD: </strong><%= access_point.password %></p>
</div>
</div>
</div>


create.js.erb



$('#access-points-cards').append('<%= j render partial: 'access_point', locals: { access_point: @access_point }, layout: 'layouts/col-md-4' %>')
$('#new-access-point').modal('hide')


and I´m using a modal form, with remote: true to create it, after inserting the EDIT button don´t show up in the browser, but show in the dev tools, if I hit F5 it shows everything ok, don´t know if its a turbolinks problem or something like that.



Can you help me?










share|improve this question













Yo guys, I'm learning Rails and having a interesing problem



I have a this partial.



_access_point.html.erb



<div class="card">
<div class="card-body">
<div class="card-title">
<h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3>
</div>
<div class="card-text">
<p><strong>Manufacturer: </strong><%= access_point.manufacturer %></p>
<p><strong>Serial number: </strong><%= access_point.serial_number %></p>
<p><strong>USER: </strong><%= access_point.user %></p>
<p><strong>PASSWORD: </strong><%= access_point.password %></p>
</div>
</div>
</div>


create.js.erb



$('#access-points-cards').append('<%= j render partial: 'access_point', locals: { access_point: @access_point }, layout: 'layouts/col-md-4' %>')
$('#new-access-point').modal('hide')


and I´m using a modal form, with remote: true to create it, after inserting the EDIT button don´t show up in the browser, but show in the dev tools, if I hit F5 it shows everything ok, don´t know if its a turbolinks problem or something like that.



Can you help me?







javascript ruby-on-rails ruby ruby-on-rails-5






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 14:15









Joz

1




1












  • So the _access_point partial isn't rendered at all or there are some problems with it after it got rendered?
    – bernstein7
    Nov 8 at 16:03










  • it is rendered normally. <h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3> in this part of the partial, the link_to_unless_current works normally, but the fa_icon doesn´t show
    – Joz
    Nov 9 at 10:13




















  • So the _access_point partial isn't rendered at all or there are some problems with it after it got rendered?
    – bernstein7
    Nov 8 at 16:03










  • it is rendered normally. <h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3> in this part of the partial, the link_to_unless_current works normally, but the fa_icon doesn´t show
    – Joz
    Nov 9 at 10:13


















So the _access_point partial isn't rendered at all or there are some problems with it after it got rendered?
– bernstein7
Nov 8 at 16:03




So the _access_point partial isn't rendered at all or there are some problems with it after it got rendered?
– bernstein7
Nov 8 at 16:03












it is rendered normally. <h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3> in this part of the partial, the link_to_unless_current works normally, but the fa_icon doesn´t show
– Joz
Nov 9 at 10:13






it is rendered normally. <h3 class="text-center"><%= link_to_unless_current access_point.model.upcase, [access_point] %><%= link_to [:edit, access_point], remote: true, class: 'float-right' do fa_icon 'edit lg' end %></h3> in this part of the partial, the link_to_unless_current works normally, but the fa_icon doesn´t show
– Joz
Nov 9 at 10:13














1 Answer
1






active

oldest

votes

















up vote
1
down vote













Your problem should be the view is not being updated in the DOM properly.
So instead of appending try this:




  • Render your access_point view on your page always


  • Change your partial to be hidden with:



    access_point.html.erb :
    <div class="card hidden">

    some_css_file :
    hidden { display: none }




  • Show partial on js call
    create.js.erb



    $('.card').show()
    $('#new-access-point').modal('hide')



  • Decide where to place $('.card').hide() if needed







share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209574%2fruby-on-rails-partial-not-rendering-link-on-creation%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Your problem should be the view is not being updated in the DOM properly.
    So instead of appending try this:




    • Render your access_point view on your page always


    • Change your partial to be hidden with:



      access_point.html.erb :
      <div class="card hidden">

      some_css_file :
      hidden { display: none }




    • Show partial on js call
      create.js.erb



      $('.card').show()
      $('#new-access-point').modal('hide')



    • Decide where to place $('.card').hide() if needed







    share|improve this answer

























      up vote
      1
      down vote













      Your problem should be the view is not being updated in the DOM properly.
      So instead of appending try this:




      • Render your access_point view on your page always


      • Change your partial to be hidden with:



        access_point.html.erb :
        <div class="card hidden">

        some_css_file :
        hidden { display: none }




      • Show partial on js call
        create.js.erb



        $('.card').show()
        $('#new-access-point').modal('hide')



      • Decide where to place $('.card').hide() if needed







      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Your problem should be the view is not being updated in the DOM properly.
        So instead of appending try this:




        • Render your access_point view on your page always


        • Change your partial to be hidden with:



          access_point.html.erb :
          <div class="card hidden">

          some_css_file :
          hidden { display: none }




        • Show partial on js call
          create.js.erb



          $('.card').show()
          $('#new-access-point').modal('hide')



        • Decide where to place $('.card').hide() if needed







        share|improve this answer












        Your problem should be the view is not being updated in the DOM properly.
        So instead of appending try this:




        • Render your access_point view on your page always


        • Change your partial to be hidden with:



          access_point.html.erb :
          <div class="card hidden">

          some_css_file :
          hidden { display: none }




        • Show partial on js call
          create.js.erb



          $('.card').show()
          $('#new-access-point').modal('hide')



        • Decide where to place $('.card').hide() if needed








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 8 at 17:08









        Federico

        5311




        5311






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209574%2fruby-on-rails-partial-not-rendering-link-on-creation%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()