skip to Main Content

Is there any method to render a certain partial after page load?

I have the following code:

<div class="row document_display custom_scrollbar">
 <div class="col-10">
  <div class="row">

   {{> document_whiteBox column="6" public_source="true" title="Título do Documento" author="João Dezembro" data="10 de maio de 2018" content="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad runt mollit anim id est laborum."}}

  </div>
 </div>
</div>

There is the partial document_whiteBox that receives some aruments. This document loads dynamically, that is, the more I scroll, the more documents it loads (like the facebook feed)

I would like to retrieve the server information via API and render this document_whiteBox during the scroll.

It’s possible?

2

Answers


  1. Chosen as BEST ANSWER

    I was able to solve it like this:

    I render a template without any content with the display: none when I retrieve the content, I use JQUERY to create an element based on this hidden template

    Hidden div with templates

    <div id="templates" style="display:none">
      {{> document_whiteBox column="3" public_source="false" title="" author="" data="" content=""}}
      {{> block_container_list}}
    </div>
    

    Code to generate an element based on a template:

    this.$template_document = $("#templates").find(".doc_whitebox").prop('outerHTML')
    this.$template_block = $("#templates").find(".block_container_list").prop('outerHTML')
    
    let el = $.parseHTML(this.$template_document)
    $(el).find(".title_whiteBox_archive").find("span").text(doc_version.title)
    (...)
    

  2. I’m afraid that’s not possible. Your template processing is over then.

    What you can do is to put an even on scroll that will display the next event by reexecuting the code on the right data.

    Otherwise another solution (but more costly) is to return all data to the client and hide the parts until the user scrolls.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search