PricingBlog

How to access content in contenteditable div?

  • rscott-1211427865980051617

    Bishop

    1 year ago

    I'm using essentially the same logic as accessing content as it changes in a textarea, but the only difference is that its coming up undefined when i try to access Event, target, value.

    How can I access whatever is inside the div's text so I can save it?
    1211427866903060540-Screenshot_2024-02-25_at_3.39.58_PM.png
    1211427866479165500-Screenshot_2024-02-25_at_3.39.54_PM.png
    1
  • its the 'set answer: value' where its getting 'undefined' as i type in the contenteditable text.
  • rscott-1211430851632562196

    Bishop

    1 year ago

    when i enter info in the contenteditable div and access it via dom, i get this [object HTMLDivElement] and so thought the following would work to access it
    1211430851426918420-Screenshot_2024-02-25_at_3.52.48_PM.png
  • 1211430873728028742-Screenshot_2024-02-25_at_3.52.08_PM.png
  • but that returns undefined?
  • rscott-1211431277887229962

    Bishop

    1 year ago

    .innertext added to htmldivelement
  • rscott-1211431929572884560

    Bishop

    1 year ago

    this seemed like it should work
    1211431929346265148-Screenshot_2024-02-25_at_3.57.34_PM.png
  • but it didn't
  • rscott-1211432234725154817

    Bishop

    1 year ago

    using innerText actually causes it to all blank out when i start typing. that is interesting...
  • rscott-1211435291294957578

    Bishop

    1 year ago

    i looked at the source
    and it shows my contenteditable div with a span in it, so i tried this following Get and it just now says 'undefined' again
    1211435291051692102-Screenshot_2024-02-25_at_4.08.53_PM.png
  • 1211435311696191488-Screenshot_2024-02-25_at_4.10.35_PM.png
  • rscott-1211436314591760414

    Bishop

    1 year ago

    is there a way to do this?
    1211436314357006346-Screenshot_2024-02-25_at_4.15.16_PM.png
  • rscott-1211445256042709102

    Bishop

    1 year ago

    Ok so I had to make an action that triggered an event to get the data back to toddle.

    So if anyone needs it here is the action to read the contents of contenteditable=true texts in toddle.

    I think its a bit clunky and would love to see it built into toddle itself as a formula.
    1211445255862358056-Screenshot_2024-02-25_at_4.50.12_PM.png
  • jacobkofoed-1211592523097702420

    Jacob Kofoed

    1 year ago

    There is no testdata on the event - I'll see if I can add it - but you can use Get.

    The screenshot is from our canvas implementation in toddle, where we let you edit text directly in the canvas, using contenteditable. That's how we handle it without any cusom code 👍 It is set on the input event on the element with contenteditable.
    1211592522921549875-CleanShot_2024-02-26_at_09.32.23.png
    ❤️1