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

119
Views
¿Cómo llamar a las funciones js definidas en la etiqueta de script del archivo erb?

Tengo un diseño para PDF ( views/layouts/pdf.html.erb ):

 <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="https://cdn.tailwindcss.com"></script> <script> function sayHello() { return "HAAHAHAhAHAAH" } </script> <style> </style> </head> <body> <%= yield %> </body> </html>

Quiero usar esa función sayHello() dentro de la etiqueta ap en app/views/invoices/pdf.html.erb , que se incrusta en el yield de layouts/pdf.html.erb

Intenté llamar a sayHello() de diferentes maneras, como usar <%= javascript: sayHello()%> , etc., pero nada funciona.

También intenté mantener sayHello() en un archivo separado y luego hacer referencia a él en javascript_pack_tag en layouts/pdf.html.erb , lo que genera un error diferente.

¿Hay alguna forma de acceder a esa función en html.erb?

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

0

Dale a tu párrafo una clase así:

 <p class="p_class"></p>

entonces pon esto

 <script> document.getElementsByClassName('p_class')[0].textContent = sayHello(); </script>

en la parte inferior de su app/views/invoices/pdf.html.erb parcial.

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!