saadqbal / HiGoogleFonts

HiGoogleFonts allows you to add a Google font picker to easily display a list of Google fonts. The picker shows an instant preview of the font style without loading the font css.
Apache License 2.0
48 stars 6 forks source link

400 error trying to load "Missing..." text as a font #9

Open froggerjohn opened 6 years ago

froggerjohn commented 6 years ago

From the select2 documentation: Anything rendered in the results is templated. This includes results such as the "Searching..." and "Loading more..." text which will periodically be displayed, which allows you to add more advanced formatting to these automatically generated options. You must ensure that your templating functions can support them.

This wasn't being handled, which resulted in 400 errors trying to GET from: https://fonts.googleapis.com/css?family=Searching%E2%80%A6

It's fixable by adding this to the top of the templateResult callback:

if (!result.id)
{
return result.text;
}