Skip to content
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

Select value based on url query #27

Open
lautarovc opened this issue Jun 16, 2021 · 1 comment
Open

Select value based on url query #27

lautarovc opened this issue Jun 16, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@lautarovc
Copy link

Is your feature request related to a problem? Please describe.
It would be very useful if we could set the selected value with a URL query parameter. I'm not sure if there's a way to achieve this manually.

Describe the solution you'd like
To be able to add the value I want for the select through the URL, something like: ?select-linux-distro=arch-linux

Describe alternatives you've considered
I've been trying to set it manually through a JS listener but haven't been very successful

@lautarovc lautarovc added the enhancement New feature or request label Jun 16, 2021
@lautarovc
Copy link
Author

If anyone's interested, I figured a way with onload and onhashchange listeners:

  • The id of the select element is the label in lower-case and hyphenated, so just get the select element by that id and set the value taken from the URL.
  • Search for the element that has data-select-content attribute as the original lower-case and hyphenated value of the select and remove the class docsify-select__content--active.
  • Search for the element that has data-select-content attribute as the new lower-case and hyphenated value of the select and add the class docsify-select__content--active.

Still would be cool to have it included in the plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant