Auto-focus the post text box on new post
This commit is contained in:
parent
44d35c6ccb
commit
c943864edc
|
|
@ -2,12 +2,13 @@ import { Controller } from "@hotwired/stimulus"
|
||||||
import { showToast } from "../services/toast";
|
import { showToast } from "../services/toast";
|
||||||
|
|
||||||
export default class PosteditController extends Controller {
|
export default class PosteditController extends Controller {
|
||||||
|
static targets = ['bodyTextEdit'];
|
||||||
static values = {
|
static values = {
|
||||||
saveAction: String,
|
saveAction: String,
|
||||||
};
|
};
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
console.log("connected");
|
this.bodyTextEditTarget.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
async save(ev) {
|
async save(ev) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<input type="text" name="title" class="form-control" placeholder="Title" value="{{ .post.Title }}">
|
<input type="text" name="title" class="form-control" placeholder="Title" value="{{ .post.Title }}">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<textarea name="body" class="form-control" rows="3">{{.post.Body}}</textarea>
|
<textarea data-postedit-target="bodyTextEdit" name="body" class="form-control" rows="3">{{.post.Body}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ if $isPublished }}
|
{{ if $isPublished }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue