Add auto-save to the draft comment field
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static outlets = [ "auto-save" ]
|
||||
|
||||
change(event) {
|
||||
this.autoSaveOutlet.change(event)
|
||||
}
|
||||
|
||||
submit() {
|
||||
this.autoSaveOutlet.submit()
|
||||
}
|
||||
}
|
||||
@@ -101,8 +101,9 @@
|
||||
<% if @bubble.published? %>
|
||||
<%= render "bubbles/messages", bubble: @bubble %>
|
||||
<% else %>
|
||||
<form>
|
||||
<%= tag.house_md @bubble.draft_comment, name: "bubble[draft_comment]", form: "bubble_form", placeholder: new_comment_placeholder(@bubble) %>
|
||||
<form data-controller="remote-auto-save" data-remote-auto-save-auto-save-outlet="#bubble_form">
|
||||
<%= tag.house_md @bubble.draft_comment, name: "bubble[draft_comment]", form: "bubble_form", placeholder: new_comment_placeholder(@bubble),
|
||||
data: { action: "house-md:change->remote-auto-save#change focusout->remote-auto-save#submit" } %>
|
||||
</form>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user