AnswerDotAI / AnswerDotAI/MonsterUI

CodeBlock editable not sending ajax content

Open
#78 1 comment 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
Jupyter Notebook
Stars
522
Forks
33
Avg merge
1m
Merged PRs (30d)
1

Description

Hi, I'm trying get the updated contents of an editable CodeBlock, when it is updated, with no luck. I've tried with and without an enclosing Form tag. I've also tried getting content from body and from the form request, same result. With TextArea is working as expected.

Below is a sample code to reproduce the issue:

```python
from fasthtml.common import *
from monsterui.all import *

app, rt = fast_app(hdrs=Theme.blue.headers())

@rt
def index():
return DivHStacked(
Div(
TextArea(
"Initial area here",
id="area-editor",
name="text-editor",
hx_post="/save-code",
hx_trigger="change, keyup delay:500ms changed",
)
),
Form(
CodeBlock(
"Initial code here",
contenteditable="true",
spellcheck=False,
id="code-editor",
name="text-editor",
hx_post="/save-code",
hx_trigger="keyup delay:500ms"
),
)
)

@rt("/save-code")
async def post(req):
form = await req.form()
print("FORM:", form)
code = form.get("text-editor")
# # body = await req.body()
# # code = body.decode('utf-8')
print("CODE:", code)
return f"{code} Saved!"

serve()

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.