can't download wordpress posts using javascript

22
April 07, 2021, at 6:50 PM

hello i have a list of posts and i use javascript to download a post as pdf but i have a problem because the download button works just on the first post and not in the others and when i inspect the button in the browser i can see the description below but the button not working

this is a part of my code if some one could help :

ps: the download button is : Imprimer l'offre

<li style=" border: 1px solid black; padding: 20px; margin-bottom: 30px;" <?php job_listing_class(); ?> data-longitude="<?php echo esc_attr($post->geolocation_long); ?>" data-latitude="<?php echo esc_attr($post->geolocation_lat); ?>">
  <!--  <a href="<?php the_job_permalink(); ?>">
     -->
  <!-- <?php the_company_logo(); ?> -->
  <div class="work-section">
    <h3><?php wpjm_the_job_title(); ?> <?php echo "Job ID: " . $post->ID ?> </h3>
    <!-- <div class="company">
                    <?php the_company_name('<strong>', '</strong> '); ?>
                    <?php the_company_tagline('<span class="tagline">', '</span>'); ?>
                </div> -->
  </div>
  <!-- <div class="location">
                <?php the_job_location(false); ?>
            </div> -->
  <div id="tblCustomers">
    <div id="collapseExample<?php echo  $post->ID ?>" class=" collapse job_description">
      <?php wpjm_the_job_description(); ?>
    </div>
    <div id="print-btn"></div>
  </div>
  <center>
    <div class="vc_btn3-container  red-btn vc_btn3-inline" style="margin-top: 20px">
      <button id="pdfview" data-target="<?php echo  $post->ID ?>" style="text-align: center;">
        Imprimer l’offre
      </button>
      <div id="pdfdiv" style="display: none;">
        <?php wpjm_the_job_description(); ?>
      </div>
      <div id="editor"></div>
      <script type="text/javascript">
        var $ = jQuery.noConflict();
        $(window).on('load', function() {
          var doc = new jsPDF();
          var specialElementHandlers = {
            '#editor': function(element, renderer) {
              return true;
            }
          };
          $('#pdfview').click(function() {
            doc.fromHTML($('#pdfdiv').html(), 15, 15, {
              'width': 700,
              'elementHandlers': specialElementHandlers
            });
            doc.save('file.pdf');
          });
        });
      </script>
    </div>
READ ALSO
How to add string into a RealmList Kotlin

How to add string into a RealmList Kotlin

it`s my first question in stackOverflow, and i need help with how to insert data (Strings) into a RealmList

36
Selecting Names with Highest Aggregate in each Class

Selecting Names with Highest Aggregate in each Class

I'm new to SQL and I'm working with the following tables:

34
save file and his data at the same time with the foreign key of the file

save file and his data at the same time with the foreign key of the file

i'm new here and i have a problem for saving a file and his data at the same time with the foreign key

42