use-bootstrap / use-bootstrap-select

Create a select element using the native Bootstrap 5 dropdown UI.
http://use-bootstrap-select.js.org/
MIT License
18 stars 3 forks source link

Some things I couldn't do #14

Open mustafavanli opened 1 month ago

mustafavanli commented 1 month ago

Is it possible to give a method that will trigger while creating? AND How I adding options to optgroup?

pardeyke commented 1 month ago

You can add option groups like so:


<select id="example" class="form-select">
  <optgroup label="Fruit">
    <option value="apple">Apple</option>
    <option value="banana">Banana</option>
    <option value="grape">Grape</option>
    <option value="kiwi">Kiwi</option>
    <option value="orange">Orange</option>
    <option disabled value="snake_fruit">Snake fruit</option>
  </optgroup>
  <optgroup label="Vegetable">
    <option value="broccoli">Broccoli</option>
    <option value="carrot">Carrot</option>
    <option value="cucumber">Cucumber</option>
    <option disabled value="eggplant">Eggplant</option>
    <option value="spinach">Spinach</option>
    <option value="tomato">Tomato</option>
  </optgroup>
</select>
mustafavanli commented 1 month ago

At first, the select element will be empty.

pardeyke commented 1 month ago

What do you mean? When pasting the above code in an html page, this is the result:

Screenshot 2024-07-24 at 19 22 38

What else do you expect?

mustafavanli commented 1 month ago

I fill out my select option only according to the response from axios. How do I group and add data from response?