https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • e

    echoing-action-55459

    10/27/2022, 10:48 PM
    I think for boosted its the same no? The issue I'm gonna have next is I want to add new html to the page and their head tags appended and not to mess with what exists.
  • m

    mysterious-toddler-20573

    10/27/2022, 10:49 PM
    yes
  • m

    mysterious-toddler-20573

    10/27/2022, 10:49 PM
    I'm adding a directive,
    hx-head
    that allows you to specify how to treat the head elements
  • m

    mysterious-toddler-20573

    10/27/2022, 10:50 PM
    e.g.
    Copy code
    html
    <head hx-head="append">
         <link rel="stylesheet" href="page-style.css">
    </head>
    would append the link to the head if it didn't exist
  • m

    mysterious-toddler-20573

    10/27/2022, 10:51 PM
    Copy code
    html
    <head hx-head="append-always">
         <link rel="stylesheet" href="page-style.css">
    </head>
    would append the link even if it already existed
  • m

    mysterious-toddler-20573

    10/27/2022, 10:51 PM
    etc.
  • m

    mysterious-toddler-20573

    10/27/2022, 10:51 PM
    people have also asked for the ability to re-execute a script
  • m

    mysterious-toddler-20573

    10/27/2022, 10:52 PM
    it's a challenging problem for htmx, because you can both have full page boosted responses as well as partial bits of HTML, and so the behavior of the head tag isn't as straight forward as, for example, in turbolinks
  • m

    mysterious-toddler-20573

    10/27/2022, 10:52 PM
    so I need to think (and help thinking) about it
  • e

    echoing-action-55459

    10/27/2022, 10:54 PM
    I think the calling element should determine how it should handle the head tags
  • e

    echoing-action-55459

    10/27/2022, 10:54 PM
    append-always may result in too much in there if it's always appending
  • e

    echoing-action-55459

    10/27/2022, 10:55 PM
    like boosting is like a anchor link page refresh it's different then a targeted append
  • e

    echoing-action-55459

    10/27/2022, 10:55 PM
    boosting should kind of be sync, targing should be append
  • m

    mysterious-toddler-20573

    10/27/2022, 10:55 PM
    mmm
  • m

    mysterious-toddler-20573

    10/27/2022, 10:55 PM
    should it be controlable w/ an attribute?
  • m

    mysterious-toddler-20573

    10/27/2022, 10:56 PM
    to override the default
  • m

    mysterious-toddler-20573

    10/27/2022, 10:56 PM
    I think I agree w/ the defaults: * boosted is sync * non-boosted is append (if absent)
  • m

    mysterious-toddler-20573

    10/27/2022, 10:57 PM
    some other concepts I'm considering working in:
    hx-head="sticky"
    this element will never be removed from the head
  • m

    mysterious-toddler-20573

    10/27/2022, 10:57 PM
    hx-head="reexecute"
    this element will be re-executed/added on every request
  • m

    mysterious-toddler-20573

    10/27/2022, 10:58 PM
    but then, on boosted pages, we probably always want to re-execute all the javascript
  • m

    mysterious-toddler-20573

    10/27/2022, 10:58 PM
    😑
  • m

    mysterious-toddler-20573

    10/27/2022, 10:58 PM
    I'm going to start a gist on this
  • b

    busy-action-85810

    10/27/2022, 11:05 PM
    Slight change of topic...but should it be possible to make a delete request where the server answers a 204 - No Content. Here's example Ruby code:
    Copy code
    # View
    # The parent element has these attributes: "hx-trigger" => "click", "hx-swap" => "outerHTML".
    <%= link_to "Delete",
                task_path(task),
                class: "button button-decline",
                data: {"hx-target" => "closest .task", "hx-delete" => task_path(task)} %>
    Copy code
    # Controller Action
    def destroy
      Task.find(params[:id]).destroy!
      head :no_content
    end
    Does HTMX not respect 204 when swapping?
  • m

    mysterious-toddler-20573

    10/27/2022, 11:06 PM
    204 means no content has been given by the server, so no swap occurs
  • m

    mysterious-toddler-20573

    10/27/2022, 11:06 PM
    this is, unfortunately, an ambiguity in the the meaning of "No Content"
  • m

    mysterious-toddler-20573

    10/27/2022, 11:06 PM
    we've argued about it a lot
  • b

    busy-action-85810

    10/27/2022, 11:06 PM
    Oh, OK, so perhaps I shouldn't swap at all but completely remove the effected HTML element?
  • m

    mysterious-toddler-20573

    10/27/2022, 11:07 PM
    one sec
  • g

    gorgeous-airport-54386

    10/27/2022, 11:07 PM
    Just return 200
  • m

    mysterious-toddler-20573

    10/27/2022, 11:08 PM
    https://htmx.org/docs/#modifying_swapping_behavior_with_events
1...876877878...1146Latest