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

132
Vistas
Uncaught SyntaxError: expected expression, got ';'
var popupContent = '<a href="#tableofresults" class="modal-trigger" onClick="stopno='+feature.properties.busstopcode+'; nuscode="'+feature.properties.nuscode+'";">Click me!</a>';

I'm currently using Leaflet and want a popup with clickable text, which will run some Javascript to define the variables stopno and nuscode. However, in the GeoJSON data feature.properties.nuscode is a string and not an integer, and thus I need to use quote marks to define the variable nuscode.

However, if I were to use quote marks again it would cause issues as I am using inline JS in the onclick property for the <a> tag, and using quote marks causes "Unexpected end of input" errors. How do I remedy this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As of ES2015, you could use backticks to create what is known as template literals (template strings).

You can encapsulate text in backticks and interpolate JavaScript so that your code is much neater. It also helps avoid any conflicting use of single/double quotation marks, and avoids having to escape (\) strings.

More can be read about it here on MDN

const popupContent = `<a href="#tableofresults" class="modal-trigger" onClick="stopno='${feature.properties.busstopcode}'" nuscode="${feature.properties.nuscode}">Click me!</a>`;
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