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

183
Vistas
JavaScript - conditional formatting within a tooltip

I have a tooltip string builder line like this:

    scheduler.templates.tooltip_text = function(start,end,event)  
    {
        return "<strong style=\"font-size:16px;\"><a href=\"https://www.somewebsitethatshowsmoredetails.com/details:"+event.IMO+"/something:"+event.text+"\" target=\"_blank\">"+event.text+"</a></strong>"+" "+event.BubbleCode+
            "<ul><li><strong>.....and other html injection here"
    };

The tooltip, shows a URL link and some data fed from the 'event' object.

One of those details is 'event.BubbleCode', which has one value at any one time, a numeric 0, 1, 2 or 3.

Is there a way to place an switch() statement or some logic within the string line above to turn that BubbleCode value into a colored character such as an asterisk?

Something like this...BUT for the '3' to be a GREEN asterisk, or if it's a value of '2' for it to be a RED asterisk.

enter image description here

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

0

You could use a span and set its color. If your "switch" should be inline just use an object and access it at event.BubbleCode.

It could look like this:

    scheduler.templates.tooltip_text = function(start,end,event)  
    {
        return "<strong style=\"font-size:16px;\"><a href=\"https://www.somewebsitethatshowsmoredetails.com/details:"+event.IMO+"/something:"+event.text+"\" target=\"_blank\">"+event.text+"</a></strong><span style=\"color:" + {0:'black',1:'yellow',2:'red',3:'green'}[event.BubbleCode] + ";\">*</span>"+
            "<ul><li><strong>.....and other html injection here"
    };
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