Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
How to call function using Nunjucks?

I want to call the jQuery function in HTML using Nunjucks, but it's giving me an error. I have imported the JS file into the HTML file.

Error: Unable to call 'fooName', which is undefined or falsey

Does anyone know why I can't call the function? Here is my code example:

<a class="btn" onclick="{{fooName(test)}}" href="#">Click me!</a>
$(document).ready(() => {
  const fooName = (name) => {
    console.log(`${this.name}`)
  };
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

My situation was a bit different but still I think it works in this case too

The idea is to add a function to the global window object

Within the view render method that passes variables to nunjucks I added this function

var self = this;

window.onClick = function (id) {
 // self.fetchData(id);
 // Do something
}

and within nunjucks

<a class="btn" onclick="window.onClick({{item.id}})">Click me!</a>

it works perfectly.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda