Search code examples
amp-htmlaccelerated-mobile-page

How can I select all options of a multiple amp-selector?


I have an amp-selector with multiple options. I know that if I want to clear all the selections, I can bind <apm-selector-id>.clear on a tap event on a button.

Example:

<button on="tap:mySelector.clear">Clear Selection</button>

Is there a way I can do something similar in order to select all options? I have many options and I do not want to compel my user to click on each one of them, if they want to select them all. I just want them to click on a button and have all options selected, all together, with one click.


Solution

  • Currently there is no action registered that does what you are asking.

    amp-selector source

    However, you can fork the repo on github, add the functionality and do a pull request. It's pretty simple and easy to do.

    Another option you have is to start out with all options selected and have the user deselect the undesired ones.