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

129
Views
Ejecute el código javascript presente dentro de la plantilla secundaria después de que se represente la plantilla principal

Tengo una plantilla base que sirve como estructura común para las plantillas secundarias. Dentro de esta plantilla base, tengo la biblioteca jQuery incluida justo antes de la etiqueta del body de cierre.

plantilla base

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> . . </head> <body> {% block content %} {% endblock %} <script src="path/to/jQuery/library"></script> </body> </html>

Ahora mi plantilla secundaria tiene el siguiente código

plantilla infantil

 {% extends 'base_template.html' %} {% block content %} <h1>How you doing?</h1> <script type="text/javascript"> // this code is specific to this template, may not be used in another template // but can't use jQuery here since the library hasn't loaded yet </script> {% endblock %}

Entonces, ¿cómo haría para ejecutar el código javascript dentro child template solo después de que la plantilla base haya terminado de cargar la biblioteca jQuery?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Necesitas usar 2 bloques:

base
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> . . </head> <body> {% block content %} {% endblock %} <script src="path/to/jQuery/library"></script> {% block scripts %} {% endblock %} </body> </html>
child_template
 {% extends 'base_template.html' %} {% block content %} <h1>How you doing?</h1> {% endblock %} {% block scripts %} <script type="text/javascript"> // this code can "use" jquery </script> {% endblock %}
about 4 years ago · Juan Pablo Isaza Report
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!