PricingBlog

Event listeners on a <slot>

  • alfred_66594-1212318317986193438

    Alfred

    1 year ago

    Is it possible to natively create event listeners in Toddle that are triggered on a <slot> element whenever the node contained within that slot changes? Or should I implement this functionality through a custom function? My use case involves a button component with 'before' and 'after' slots for icons. When an icon is present, the padding on the corresponding side of the icon should change from 8px to 4px. Currently, I use two attributes on the component: has_before_icon and has_after_icon. Additionally, I have a formula handle_btn_padding, which sets a style variable for the padding.
  • rscott-1212581528211685456

    Bishop

    1 year ago

    What are you trying to do - I don't fully understand. It doesn't feel like slots are needed if you are using the same basic content in each - it feels like components would get you there, but I don't know exactly what you are trying to do - and I'm just studying slots, the last piece I haven't used.
  • rscott-1212593547090333737

    Bishop

    1 year ago

    variables inside the same html elements: variables. collections of html elements with various variables and apis that only change the contents of: components. changing the actual HTML elements themselves: slots. Your use case from what little I know of it doesn't seem to require slots.
  • andreasmoller-1212644531875614740

    Andreas Møller

    1 year ago

    No this is not possible today.