You are viewing limited content. For full access, please sign in.

Question

Question

How to Bold Part of Auto-Suggestions in Single Line Fields?

asked on May 2, 2024

I discovered that Auto-Suggestions on Single Line Fields have a CSS class of .ellipsis.

I want to bold the first part of each Auto-Suggestion up to the double dash in this example.  The Auto-Suggestions are generated by a Lookup Rule.

The console.logs() in the script below return correct values, but the first part of the string is still not changing to bold.  I'm missing something, but I don't know what.

I would appreciate any help you can offer...thank you!

$(document).ready(function() {
  $('#q110 input').focus(function() { 
    console.log('focused');
      $('.ellipsis').each(function() {
        let text = $(this).text();
          console.log(text);
        let dashIndex = text.indexOf('-');
          console.log(dashIndex);
        if (dashIndex != -1) {
            let firstPart = text.substring(0, dashIndex);
              console.log(firstPart);
            let restPart = text.substring(dashIndex);
              console.log(restPart);
            $(this).html('<strong>' + firstPart + '</strong>' + restPart);
        }
    });
  });
});

 

0 0

Replies

replied on May 2, 2024 Show version history

The problem is the suggested options are reloaded each time the field receives focus.  You can demonstrate this by playing around with the element in the browser inspector.  So even if your code is working, it gets overwritten by the application pretty much immediately.

Unfortunately, CSS would have been my suggestion, but after some Googling it sounds like CSS can't target part of a string of text like that.

Sorry.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.