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

    delightful-ambulance-44416

    04/02/2023, 3:10 PM
    Heyo
  • Im new here, I need some hyperview help
    d

    delightful-ambulance-44416

    04/02/2023, 3:10 PM
    Im new here, I need some hyperview help
  • Which channel should i talk on?
    d

    delightful-ambulance-44416

    04/02/2023, 3:10 PM
    Which channel should i talk on?
  • Thank
    w

    witty-garage-37227

    04/02/2023, 3:16 PM
    Thank
  • https://htmx.org/extensions/head-support/
    c

    cuddly-keyboard-70746

    04/02/2023, 4:09 PM
    https://htmx.org/extensions/head-support/
  • is it normal that htmx does not fire events declared in `"HX-Trigger"` when HTTPResponse returned with this header is 302 redirect?
    m

    microscopic-cartoon-64495

    04/03/2023, 10:32 AM
    is it normal that htmx does not fire events declared in
    "HX-Trigger"
    when HTTPResponse returned with this header is 302 redirect?
  • Htmx can't see the headers from the response, the redirect is performed by the browser automatically, so yes, it's expected
    r

    ripe-action-67367

    04/03/2023, 10:35 AM
    Htmx can't see the headers from the response, the redirect is performed by the browser automatically, so yes, it's expected
  • dumb simple question: what is the code for a button, to act as a hyperlink? ` <button htmx-attribute="/destination_page/">Not an anchor tag, a button!</button>`
    w

    white-london-59674

    04/04/2023, 1:34 PM
    dumb simple question: what is the code for a button, to act as a hyperlink?
    <button htmx-attribute="/destination_page/">Not an anchor tag, a button!</button>
  • ```html <button hx-get="/destination_page/" hx-push-url="true" hx-target="body">Not an anchor tag, a button!</button> ```
    m

    mysterious-toddler-20573

    04/04/2023, 1:37 PM
    Copy code
    html
    <button hx-get="/destination_page/"
            hx-push-url="true"
            hx-target="body">Not an anchor tag, a button!</button>
  • ```html <a href="/destination_page/">Links are non-negotiable</a> ```
    g

    gorgeous-airport-54386

    04/04/2023, 1:37 PM
    Copy code
    html
    <a href="/destination_page/">Links are non-negotiable</a>
  • but you are probably better off using a link and styling it like a button, rather than using a button as a link
    m

    mysterious-toddler-20573

    04/04/2023, 1:37 PM
    but you are probably better off using a link and styling it like a button, rather than using a button as a link
  • in that case, you can just do: ```html <a hx-boost="true" href="/whatever"> Links Are Good </a> ```
    m

    mysterious-toddler-20573

    04/04/2023, 1:38 PM
    in that case, you can just do:
    Copy code
    html
    <a hx-boost="true" href="/whatever">
       Links Are Good
    </a>
  • Not only for accessibility, but also for SEO, etc. It's more webby.
    m

    mysterious-toddler-20573

    04/04/2023, 1:38 PM
    Not only for accessibility, but also for SEO, etc. It's more webby.
  • Whadda ya know, <@249837723416788992> has already solved this exactly (great moment for shameless self-promotion Deniz -- don't worry, I got you covered!) The correct answer is, for me, is: ``` <head> <link rel="stylesheet" href="https://unpkg.com/missing.css@1.0.9/dist/missing.min.css"> </head> <a class="<button>" href="/cta">Link that looks like a button!</a> ``` https://missing.style/docs/utils/#.%3Cbutton%3E
    w

    white-london-59674

    04/04/2023, 1:46 PM
    Whadda ya know, @gorgeous-airport-54386 has already solved this exactly (great moment for shameless self-promotion Deniz -- don't worry, I got you covered!) The correct answer is, for me, is:
    Copy code
    <head>
    <link rel="stylesheet" href="https://unpkg.com/missing.css@1.0.9/dist/missing.min.css">
    </head>
    <a class="<button>" href="/cta">Link that looks like a button!</a>
    https://missing.style/docs/utils/#.%3Cbutton%3E
  • \> me using bootstrap rather than missing.css conventions
    m

    mysterious-toddler-20573

    04/04/2023, 2:15 PM
    \> me using bootstrap rather than missing.css conventions

    https://cdn.discordapp.com/attachments/725789747212976259/1092814625222963290/iu.png▾

  • Anyone noticed the link to the SSE extension is returning a 520? https://unpkg.com/htmx.org/dist/ext/sse.js
    t

    tall-sundown-41732

    04/04/2023, 3:09 PM
    Anyone noticed the link to the SSE extension is returning a 520? https://unpkg.com/htmx.org/dist/ext/sse.js
  • And now it isn't...?
    t

    tall-sundown-41732

    04/04/2023, 3:13 PM
    And now it isn't...?
  • seems like unpkg is not feeling well
    r

    ripe-action-67367

    04/04/2023, 3:20 PM
    seems like unpkg is not feeling well
  • So how is the very simple and usual case of having an hx-indicator show a spinner while an img tag is being requested by the backend server?
    r

    rich-alarm-65737

    04/04/2023, 4:53 PM
    So how is the very simple and usual case of having an hx-indicator show a spinner while an img tag is being requested by the backend server?
  • right in examples, thank you!
    r

    rich-alarm-65737

    04/04/2023, 5:21 PM
    right in examples, thank you!
  • i love htmx's banner
    s

    shy-knife-59740

    04/04/2023, 8:21 PM
    i love htmx's banner
  • on twitter
    s

    shy-knife-59740

    04/04/2023, 8:21 PM
    on twitter
  • Hello all
    c

    cool-match-83608

    04/05/2023, 6:49 AM
    Hello all
  • anyone every tried to download a file with htmx and thymeleaf while at the same time refreshing a fragment ?
    c

    cool-match-83608

    04/05/2023, 6:49 AM
    anyone every tried to download a file with htmx and thymeleaf while at the same time refreshing a fragment ?
  • Are you talking about situation when you make request with htmx, you swap some element and you want to refresh something else somewhere in the dom?
    e

    echoing-lion-55988

    04/05/2023, 9:02 AM
    Are you talking about situation when you make request with htmx, you swap some element and you want to refresh something else somewhere in the dom?
  • If so, you can trigger another requests with custom events with HX-Trigger HTTP header or hx-swap-oob attribute
    e

    echoing-lion-55988

    04/05/2023, 9:04 AM
    If so, you can trigger another requests with custom events with HX-Trigger HTTP header or hx-swap-oob attribute
  • i am trying to download a file
    c

    cool-match-83608

    04/05/2023, 9:12 AM
    i am trying to download a file
  • this is my code
    c

    cool-match-83608

    04/05/2023, 9:12 AM
    this is my code
  • @GetMapping("/reportfilegeneration/generateinvoicefile") @ResponseBody fun downloadCsv(@RequestParam(value = "report", required = true) report: String, @RequestParam(value = "dateFrom", required = true) dateFrom: String, @RequestParam(value = "dateTo", required = true) dateTo: String, response: HttpServletResponse) { if(report == "summary") { val outputStream = ByteArrayOutputStream() reportFileGenerationLifecycle.generateCsv(dateFrom.toLocalDate(), dateTo.toLocalDate(),outputStream) val contentDisposition = ContentDisposition.builder("attachment").filename("CCBLING_CCSMRY_${LocalDateTime.now()}.csv") .build() response.setHeader(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString()) //response.addHeader("HX - Trigger":"myEvent") //response.addHeader("HX-Trigger": {"event1":"A message", "event2":"Another message"}) response.contentType = MediaType.valueOf("text/csv").type response.outputStream.write(outputStream.toByteArray()) response.flushBuffer() outputStream.close() } }
    c

    cool-match-83608

    04/05/2023, 9:12 AM
    @GetMapping("/reportfilegeneration/generateinvoicefile") @ResponseBody fun downloadCsv(@RequestParam(value = "report", required = true) report: String, @RequestParam(value = "dateFrom", required = true) dateFrom: String, @RequestParam(value = "dateTo", required = true) dateTo: String, response: HttpServletResponse) { if(report == "summary") { val outputStream = ByteArrayOutputStream() reportFileGenerationLifecycle.generateCsv(dateFrom.toLocalDate(), dateTo.toLocalDate(),outputStream) val contentDisposition = ContentDisposition.builder("attachment").filename("CCBLING_CCSMRY_${LocalDateTime.now()}.csv") .build() response.setHeader(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString()) //response.addHeader("HX - Trigger":"myEvent") //response.addHeader("HX-Trigger": {"event1":"A message", "event2":"Another message"}) response.contentType = MediaType.valueOf("text/csv").type response.outputStream.write(outputStream.toByteArray()) response.flushBuffer() outputStream.close() } }
  • this is working great
    c

    cool-match-83608

    04/05/2023, 9:12 AM
    this is working great
1...108410851086...1146Latest