How to Use select2

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 12

  • @iamtafara
    @iamtafara 2 роки тому +2

    Thank you buddy,,, saved my day

  • @yordiw
    @yordiw 3 місяці тому

    Sometimes you need a random Indian guy to show you that you just forgot to include the stylesheet... Thanks mate! 🙂

  • @pjmorceyt
    @pjmorceyt 2 роки тому +1

    Hello. Thank you for this tutorial. Is it possible to have in a same page 2 different select2 (E.g. id="categories" and "id=years") and for each of one apply a different border color or a different background color? Tried to find a way but.... :(

    • @LaravelPackageTutorial
      @LaravelPackageTutorial  2 роки тому +1

      yes, you can do it. define a separate class and css

    • @pjmorceyt
      @pjmorceyt 2 роки тому

      @@LaravelPackageTutorial I have my class and related CSS. It applies the color I want indeed but when I do not apply the $('.classCategories').select2(
      {
      multiple: true,
      closeOnSelect: true
      }
      ); If I don't apply the .select2, the select object is treated as a normal select object with the colors I want. If I apply the .select2(), it is in fact a multiple select object but with any border color...

    • @LaravelPackageTutorial
      @LaravelPackageTutorial  2 роки тому +1

      @@pjmorceyt $('.classCategories').select2 use Id instead of class. and use class for CSS on selectbox html

    • @pjmorceyt
      @pjmorceyt 2 роки тому

      @@LaravelPackageTutorial Thank you for your help. I really appreciate. But I am doing something wrong for sure: ...
      $(document).ready(function () {
      $('#classCategories').select2({
      multiple: true,
      closeOnSelect: true
      });
      });
      ...
      Category 1
      Category 2
      Category 3
      Category 4
      ...
      CSS:
      .classCategories {
      border: 1px solid green;
      }
      ...
      Result: the border is not green

    • @LaravelPackageTutorial
      @LaravelPackageTutorial  2 роки тому

      @@pjmorceyt follow this solution stackoverflow.com/questions/43051735/how-can-i-set-a-border-around-each-of-my-select2-select-box or stackoverflow.com/questions/51369304/select2-from-select-with-required-not-change-border-color

  • @RayxanGM
    @RayxanGM 2 роки тому

    And if I wanted to save the Dynamic options?

  • @victorynwefo5989
    @victorynwefo5989 2 роки тому

    10:46