Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
Hide some element if user not logged in inside Javascript Class

I want to hide some div if user not logged in, this class gonna be exported to next JS file. So I make this code inside my javascript class to hide it if user not logged in. Otherwise, it's not showing:

class DisasterData {
  static async getAllDisaster() {
    ...
      if (marker.longitude !== null && marker.latitude !== null) {
        if (shouldSkip) {
          return;
        }
        if(true) {
          ...
              <button type="submit" 
              class="popup-disaster-delete-button" 
              id="delete-button-${marker.id_logs}" data-id="${marker.id_logs}">Delete</button><br><br>
              <button type="submit" 
              class="popup-disaster-update-button"
              id="update-button-${marker.id_logs}" data-id="${marker.id_logs}" data-status="${marker.status} style="<?php 
                                      if(isset($_SESSION["login"])){
                                        echo 'display:block;';
                                      }
                                      else{
                                        echo 'display:none;';
                                      } 
                                    ?>">Update</button>
            </div>
          `;
          ...
    });
    return markers;
  }
}

export default DisasterData;

It not showing me error, but not working properly as checking if user logged in or not.

Anyways to hide it?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!