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

    mysterious-toddler-20573

    03/06/2023, 1:19 PM
    Can you place a
    <div>
    around the for loop and put the hx-sync on that?
  • h

    hallowed-pillow-66838

    03/06/2023, 1:20 PM
    I just did, not working
  • m

    mysterious-toddler-20573

    03/06/2023, 1:20 PM
    also, ids should be unique, so emitting more than one div w/ the same id isn't well formed HTML
  • m

    mysterious-toddler-20573

    03/06/2023, 1:20 PM
    OK, let me code up a same example for you
  • h

    hallowed-pillow-66838

    03/06/2023, 1:22 PM
    That was easy but this div makes no change
  • m

    mysterious-toddler-20573

    03/06/2023, 1:23 PM
    what behavior are you seeing?
  • h

    hallowed-pillow-66838

    03/06/2023, 1:23 PM
    same as without it
  • m

    mysterious-toddler-20573

    03/06/2023, 1:23 PM
    what is that behavior
  • h

    hallowed-pillow-66838

    03/06/2023, 1:24 PM
    every time I click #project - I get the page from the hx-get and I am able to get multiple of those for each 'project' in a list at the same time
  • m

    mysterious-toddler-20573

    03/06/2023, 1:28 PM
    Can you set a break point here: https://github.com/bigskysoftware/htmx/blob/5de968e933137af970644be1672a4b6eff60dc5d/src/htmx.js#L3386
  • m

    mysterious-toddler-20573

    03/06/2023, 1:28 PM
    and see if the abort event is being triggered and on the proper element, when you have that hx-sync="this:replace"
  • m

    mysterious-toddler-20573

    03/06/2023, 1:29 PM
    to be clear, when a user clicks a div you want the latest click request to replace any previous requests in flight, correct?
  • h

    hallowed-pillow-66838

    03/06/2023, 1:31 PM
    correct
  • h

    hallowed-pillow-66838

    03/06/2023, 1:31 PM
    looking at js code and trying to figure our what I should do
  • m

    mysterious-toddler-20573

    03/06/2023, 1:31 PM
    this part of the code is pretty hairy, not gonna sugar coat it
  • m

    mysterious-toddler-20573

    03/06/2023, 1:32 PM
    https://github.com/bigskysoftware/htmx/blob/5de968e933137af970644be1672a4b6eff60dc5d/src/htmx.js#L2700
  • m

    mysterious-toddler-20573

    03/06/2023, 1:32 PM
    this is where we resolve the element we are using to sync
  • t

    tall-dinner-62086

    03/06/2023, 1:32 PM
    You're replacing the actual div that is clicked with fetched data, right? What are you expecting to happen when you click a different div?
  • m

    mysterious-toddler-20573

    03/06/2023, 1:32 PM
    This is where we trigger the abort event: https://github.com/bigskysoftware/htmx/blob/5de968e933137af970644be1672a4b6eff60dc5d/src/htmx.js#L2700
  • m

    mysterious-toddler-20573

    03/06/2023, 1:33 PM
    and then the first link is where we capture that event and actually cancel the request
  • t

    tall-dinner-62086

    03/06/2023, 1:33 PM
    also you're still using the same id for all your divs. That's not gonna help.
  • t

    tall-dinner-62086

    03/06/2023, 1:34 PM
    browsers should just crash to desktop if you reuse the same id
  • h

    hallowed-pillow-66838

    03/06/2023, 1:36 PM
    I fixed the id issue but that is not the case
  • t

    tall-dinner-62086

    03/06/2023, 1:36 PM
    That was only one of your issues
  • t

    tall-dinner-62086

    03/06/2023, 1:36 PM
    But when you have multiple issues, you gotta handle them one at a time
  • t

    tall-dinner-62086

    03/06/2023, 1:37 PM
    You still haven't answered my first question, what do you expect to happen when you click a second div?
  • h

    hallowed-pillow-66838

    03/06/2023, 1:40 PM
    the second div you mean the one that's inside of the for loop?
  • t

    tall-dinner-62086

    03/06/2023, 1:40 PM
    You click a div, you replace its content with whatever
    project-update
    returns. When you click another one, what do you expect to happen?
  • h

    hallowed-pillow-66838

    03/06/2023, 1:41 PM
    I want the opened one to close and a new one to be opened
  • t

    tall-dinner-62086

    03/06/2023, 1:41 PM
    What does "close" mean?
1...105810591060...1146Latest