Sha256: a956d8fc9bc1e02564cbb222261f75c9fb3bc0991f916041cb17b3218214a952

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

<%= pb_content_tag(:li) do %>
  <% if object.variant == "radio"%>
    <%= pb_rails("radio", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
    <% if content.present? %>
      <%= content %>
    <% end %>
  <% else %>
    <%= pb_rails("checkbox", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
    <% if content.present? %>
      <%= content %>
    <% end %>
  <% end %>

  <% if object.variant == "checkbox"%>
    <script>
      var checkboxElement = document.querySelector("#<%=object.id%> input[type=checkbox]")
      
      checkboxElement.addEventListener("change", (evt) => {
        var listItemElement = document.querySelector("#<%=object.id%>")
        
        if (evt.target.checked) {
          listItemElement.classList.add("checked_item");
        } else {
          listItemElement.classList.remove("checked_item")
        }
      })
    </script>
  <% else %>
    <script>
      var radioElement = document.querySelector("#<%=object.id%> input[type=radio]")

      radioElement.addEventListener("change", () => {        
        var radios = radioElement.closest("ul").querySelectorAll("input[type=radio]")
        
        radios.forEach((radio) => {
          if (radio.checked) {
            radio.closest("li").classList.add("checked_item");
          } else {
            radio.closest("li").classList.remove("checked_item")
          }
        });
      })
    </script>
  <% end %>
<% end %>

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12820 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12816 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.26.0 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2785 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2783 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-13.25.0.pre.alpha.barchartfix2766 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb