Inline Edit

Inline edit component for in-place text editing.

python 7 params

Preview

editing
Click to edit
python
inline_edit(name='title', value='Click to edit', editing=False)

Usage

views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import InlineEdit


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.component = InlineEdit(name='title', value='Click to edit', editing=False)

    @event_handler()
    def inline_edit(self, **kwargs):
        self.component.editing = not self.component.editing
my_template.html
django
{{ component }}

Events this component sends to the view: inline_edit.

Parameters

NameTypeDefaultDescription
valuestr''current display value
namestr''field name
eventstr — renames the event''dj-input event name
editingboolFalsewhether currently in edit mode
edit_eventstr — renames the event'inline_edit'dj-click event to enter edit mode
custom_classstr''—
**kwargs— passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state——
Source & styles
FilePathNotes
moduledjust.components.components.inline_editSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 2 of this component's classes at line 1577, 2544. Override those rules, or the custom properties they read, in a stylesheet loaded after it.