-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow html for options dropdown #51
Comments
I did some investigation myself and the issue comes from client_select method where it tries to push "select" event to server with this payload:
I guess the problem lies in the fact that it tries to send back to the server the label and the value. |
I finally found how to do it reading though the code and test cases.
then I can use the option tag to customize how it renders:
I guess this needs more documentation. Can I send a PR for that? |
Hi, glad you found the right way to render HTML in the options :) Sure, go ahead and send a PR for the documentation if you feel it can be improved! Regarding highlighting the matching part of the text: this can be done on the same lines of what you're doing to show your "option.state" label. One could add the matching prefix as an additional field to the option and then render accordingly. Something like this: <:option :let={%{label: label, matching_prefix: matching_prefix}}>
<div><strong><%= matching_prefix %></strong><%= String.replace_prefix(label, matching_prefix, "") %></div>
</:option> I could add a cheatsheet that shows how to do it. What do you think? |
It would be good to add it to cheatsheet indeed. I was not able to find this from the documentation alone so it would help others |
I have a usecase for options to contain more than a text value. I want to be able to display an html I creating with label and sublabel.
I was able to display my own html sending the options like this:
but there is a problem when selecting the option from dropdown. It tries to serialize the label as json and I get a crash:
The text was updated successfully, but these errors were encountered: