chore: click to edit

This commit is contained in:
joerdav 2023-05-02 14:52:29 +01:00
parent c22ab0a793
commit e6b99f5420
No known key found for this signature in database
GPG Key ID: 7E93835EA5290C52
5 changed files with 5 additions and 13 deletions

View File

@ -17,6 +17,7 @@ var demoUser user = user{
func Handlers(prefix string, mux *http.ServeMux) { func Handlers(prefix string, mux *http.ServeMux) {
mux.HandleFunc(prefix+"/", index) mux.HandleFunc(prefix+"/", index)
mux.HandleFunc(prefix, index)
mux.HandleFunc(prefix+"/contact/1", putUser) mux.HandleFunc(prefix+"/contact/1", putUser)
mux.HandleFunc(prefix+"/contact/1/edit", editForm) mux.HandleFunc(prefix+"/contact/1/edit", editForm)
} }

View File

@ -24,7 +24,7 @@ templ Form(u user) {
</div> </div>
<div class="field is-grouped"> <div class="field is-grouped">
<div class="control"><button class="button is-black">Submit</button></div> <div class="control"><button class="button is-black">Submit</button></div>
<div class="control"><button class="button" hx-get="/click-to-edit/contact/1">Cancel</button></div> <div class="control"><button class="button" hx-get="/click-to-edit">Cancel</button></div>
</div> </div>
</form> </form>
} }

View File

@ -572,7 +572,7 @@ func Form(u user) templ.Component {
if err != nil { if err != nil {
return err return err
} }
_, err = templBuffer.WriteString(" hx-get=\"/click-to-edit/contact/1\"") _, err = templBuffer.WriteString(" hx-get=\"/click-to-edit\"")
if err != nil { if err != nil {
return err return err
} }

View File

@ -29,7 +29,7 @@ templ Layout(title string) {
</style> </style>
} }
</head> </head>
<body hx-boost="true"> <body>
@Nav() @Nav()
<div id="content" class="container p-5 content"> <div id="content" class="container p-5 content">
{ children... } { children... }

View File

@ -169,16 +169,7 @@ if err != nil {
return err return err
} }
// Element (standard) // Element (standard)
_, err = templBuffer.WriteString("<body") _, err = templBuffer.WriteString("<body>")
if err != nil {
return err
}
// Element Attributes
_, err = templBuffer.WriteString(" hx-boost=\"true\"")
if err != nil {
return err
}
_, err = templBuffer.WriteString(">")
if err != nil { if err != nil {
return err return err
} }