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

    mysterious-toddler-20573

    07/04/2020, 4:03 PM
    well, I should say, we try to do the right thing
  • b

    big-airline-13935

    07/04/2020, 8:52 PM
    @User Not boosting the links and can replicate the issue with a barebones setup: https://putyourlightson.com/test1
  • b

    big-airline-13935

    07/04/2020, 8:53 PM
    I think I've tracked down the issue, will create a bug report in github.
  • b

    big-airline-13935

    07/04/2020, 9:02 PM
    https://github.com/bigskysoftware/htmx/issues/131
  • b

    big-airline-13935

    07/04/2020, 9:19 PM
    @User Probably wise to require a specific version of htmx at this early stage, e.g. https://unpkg.com/htmx.org@0.0.7
  • m

    mysterious-toddler-20573

    07/04/2020, 10:17 PM
    @User looking at the issue, why would clicking on a link popstate? Is it due to a back button click?
  • b

    big-airline-13935

    07/04/2020, 10:18 PM
    Because the link has
    href="#xyz"
    which updates the history.
  • b

    big-airline-13935

    07/04/2020, 10:19 PM
    Through digging into the code I better understand the reasoning for restoring history from local storage.
  • m

    mysterious-toddler-20573

    07/04/2020, 10:19 PM
    so it's the back button that triggers onpopstate though, right?
  • m

    mysterious-toddler-20573

    07/04/2020, 10:19 PM
    I think I see the problem
  • m

    mysterious-toddler-20573

    07/04/2020, 10:19 PM
    I need to ensure that the pop event is from htmx, not a local nav
  • b

    big-airline-13935

    07/04/2020, 10:19 PM
    No, clicking the link does, because it updates the URL.
  • m

    mysterious-toddler-20573

    07/04/2020, 10:20 PM
    thats's a push state, no?
  • m

    mysterious-toddler-20573

    07/04/2020, 10:20 PM
    ah, looks like both
  • m

    mysterious-toddler-20573

    07/04/2020, 10:21 PM
    https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate
  • m

    mysterious-toddler-20573

    07/04/2020, 10:21 PM
    a little confusing
  • b

    big-airline-13935

    07/04/2020, 10:21 PM
    Indeed
  • m

    mysterious-toddler-20573

    07/04/2020, 10:21 PM
    i had no idea that clicking on a local anchor tag did that
  • m

    mysterious-toddler-20573

    07/04/2020, 10:22 PM
    looking back at intercooler, I do check to see if the history event was created by htmx
  • m

    mysterious-toddler-20573

    07/04/2020, 10:22 PM
    so that appears to be the fix
  • b

    big-airline-13935

    07/04/2020, 10:24 PM
    Do you agree with the premise that local cache should only be used when the pop event is from htmx? I confused myself a bit with trying to figure out what was going on and want to make sure I haven't just jumped to an inaccurate conclusion...
  • m

    mysterious-toddler-20573

    07/04/2020, 10:24 PM
    Yes.
  • b

    big-airline-13935

    07/04/2020, 10:24 PM
    Ok great
  • m

    mysterious-toddler-20573

    07/04/2020, 10:24 PM
    Copy code
    javascript
     function handleHistoryNavigation(event) {
          var data = event.state;
          if (data && data['ic-id']) {
  • m

    mysterious-toddler-20573

    07/04/2020, 10:24 PM
    that's the relevant code from intercooler
  • m

    mysterious-toddler-20573

    07/04/2020, 10:25 PM
    we only do history processing if the history event was created by intercooler
  • b

    big-airline-13935

    07/04/2020, 10:25 PM
    So if the prefix is
    ic-
    ?
  • b

    big-airline-13935

    07/04/2020, 10:25 PM
    Oh, only if
    data['ic-id']
    exists, I see.
  • m

    mysterious-toddler-20573

    07/04/2020, 10:28 PM
    https://github.com/bigskysoftware/htmx/commit/947a4470de7cca21479ed6f9a761d4bf56e451d9
  • m

    mysterious-toddler-20573

    07/04/2020, 10:28 PM
    I think that might work
1...678...1146Latest