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

181
Views
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 answers
Answer question

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 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!