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

    polite-glass-80210

    04/16/2023, 3:38 PM
    Did you ever pursue HTMX + Service Worker + PWA further? It is something that I've started putting a lot of thought towards for the project that I'm working on. Are you able to share any links to projects you've implemented any of this with?
  • n

    numerous-agent-22346

    04/16/2023, 3:57 PM
    Hi, yes I did some work and it works. I was preparing a demo but then I got less free time and I started doing something different. The demo basically works except for the last session which is not completed yet. The project is written in clojurescript and if you want I 'd be happy to share it on github The idea is very simple however:
    Copy code
    (defn init
      " - register service worker listeners"
      []
      (js/console.debug "SERVICE WORKER STARTED")
    
      (js/self.addEventListener
       "install"
       (fn []
         (js/console.debug "SERVICE WORKER Install: calling skipWaiting()")
         (.skipWaiting js/self)))
    
      (js/self.addEventListener
       "activate"
       (fn []
         (js/console.debug "SERVICE WORKER Activated: claiming clients")
         (.claim js/self.clients)
         (js/console.debug "SERVICE WORKER claimed clients. Fetch is active."))
    
       ;; PROXY SERVER HANDLER
       (js/self.addEventListener "fetch" proxy-server/handler)))
    the
    proxy-server/handler
    function takes a fetch event and returns a response by calling
    respondWith
    on the event
  • p

    polite-glass-80210

    04/16/2023, 4:03 PM
    Thanks! I'd love to see the code if you're willing to share it!
  • n

    numerous-agent-22346

    04/16/2023, 4:25 PM
    I just uploaded it here: https://github.com/DevGrammo/serviceworker-proxy-htmx
  • p

    polite-glass-80210

    04/16/2023, 4:26 PM
    Thanks! I dont know anything about Clojure, but I'm sure I'll learn a few things from it. Is there a live version somewhere on the web that I could look at?
  • n

    numerous-agent-22346

    04/16/2023, 4:38 PM
    There is no live version, if you clone/download the repo and serve the public folder, eg,
    npx serve public
    , it should work
  • p

    polite-glass-80210

    04/16/2023, 5:32 PM
    I just stumbled upon this site/blog and thought that people here would VERY much appreciate it. The depth of analysis and disdain for the web status-quo is something to behold https://infrequently.org/ Edit: wow, he's an OG in modern web stuff. Coined the phrase PWA, worked on web standards for Google and MS, etc... Hates Apple/Safari and JS frameworks.
  • m

    miniature-lizard-24702

    04/16/2023, 6:39 PM
    *sigh Hypermedia is the future we should have had
  • p

    polite-glass-80210

    04/16/2023, 6:42 PM
    It seems to be what he has been arguing and working for for the past 15 years. Each post reminds me greatly of all of the HTMX essays. Perhaps someone could bring HTMX to his attention? He seems to be in a position of influence within Microsoft's web team.
  • m

    mysterious-toddler-20573

    04/16/2023, 9:00 PM
    He has reposted some of my stuff
  • m

    mysterious-toddler-20573

    04/16/2023, 9:04 PM
    I agree w/ a lot of his observations for sure, seems like htmx would be a natural thing for him to pick up, but he hasn't really engaged
  • w

    white-rocket-20067

    04/17/2023, 2:44 PM
    I have a small widget with input elements inside a div. This widget is included in a form. When I trigger an hx-post on this widget I want to exclude all values outside of the widget. Is this possible?
  • m

    mysterious-toddler-20573

    04/17/2023, 2:47 PM
    https://htmx.org/attributes/hx-params/
  • m

    mysterious-toddler-20573

    04/17/2023, 2:48 PM
    hx-params=""
  • w

    white-rocket-20067

    04/17/2023, 2:50 PM
    Hmm I'll be having a lot of inputs there 🙂 (it's a search query builder)
  • w

    white-rocket-20067

    04/17/2023, 2:50 PM
    Thanks, I'll look into it. Pretty tired now.
  • m

    mysterious-toddler-20573

    04/17/2023, 2:55 PM
    you only want to include the current input though, right? It's a positive filter (unless you start w/ a
    not
    )
  • w

    white-rocket-20067

    04/17/2023, 2:58 PM
    No, it's a bunch of inputs. But it doesn't really matter anyway. I can ignore the post data. I've got stuff sorted out now 🙂
  • m

    mysterious-toddler-20573

    04/17/2023, 3:05 PM
    👍
  • s

    shy-knife-59740

    04/17/2023, 4:32 PM
    x-on="click"
    or
    x-trigger="click"
    ?
  • s

    shy-knife-59740

    04/17/2023, 4:42 PM
    also, how would i trigger a reload after the requests finishes for a simple get request like this?
    Copy code
    html
        <button class="cookie-btn"
                hx-get="/cookie"
                x-on="click">
            Okay
        </button>
  • r

    refined-waiter-90422

    04/17/2023, 5:19 PM
    *hx-on
  • r

    refined-waiter-90422

    04/17/2023, 5:20 PM
    also hx-on is for custom script, different from hx-trigger
  • m

    microscopic-cartoon-64495

    04/18/2023, 8:42 AM
    How to properly import extension in bundle? This gives me htmx is undefined.
    Copy code
    import 'htmx.org';
    window.htmx = require('htmx.org');
    
    import 'htmx.org/dist/ext/loading-states';
  • r

    refined-waiter-90422

    04/18/2023, 10:20 AM
    <script>
  • m

    microscopic-cartoon-64495

    04/18/2023, 11:09 AM
    I know, but I don't want to use script. Is there a way to bundle extensions?
  • s

    stocky-dentist-80693

    04/18/2023, 12:16 PM
    @microscopic-cartoon-64495 This is what I currently use:
    Copy code
    import 'htmx.org/dist/htmx.js';
    // -> `window.htmx` will now be defined
  • s

    shy-knife-59740

    04/18/2023, 12:47 PM
    Copy code
    html
    <button class="cookie-btn cookie-confirm"
            hx-get="/createsession"
            x-on="click htmx:afterRequest: alert('Done making a request!')">
        Okay
    </button>
    tried this but doesent work, without the
    click
    it wont work too, no idea why
  • r

    ripe-action-67367

    04/18/2023, 12:48 PM
    x-on
    ? Seems like a typo
  • s

    shy-knife-59740

    04/18/2023, 12:50 PM
    LMAO
1...109510961097...1146Latest