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

    abundant-spring-38265

    12/16/2022, 2:23 PM
    ok it looks like target error
  • a

    abundant-spring-38265

    12/16/2022, 2:24 PM
    which is not being picked up with hx-get is inside of select :/
  • a

    abundant-spring-38265

    12/16/2022, 2:24 PM
    i've moved it to button and it does send response
  • a

    abundant-spring-38265

    12/16/2022, 2:24 PM
    :S
  • a

    abundant-spring-38265

    12/16/2022, 2:26 PM
    ok so when i move hx-get to the outer div (input-group) it does send request
  • a

    abundant-spring-38265

    12/16/2022, 2:28 PM
    oh and yes, target div can't be inside of
  • a

    abundant-spring-38265

    12/16/2022, 2:28 PM
    so how do i make this dropdown? 😛
  • a

    abundant-spring-38265

    12/16/2022, 2:36 PM
    Almost there guys, sorry to be a pain 😦
    Copy code
    <div class="input-group">
                        <div hx-get="https://virtserver.swaggerhub.com/paulo882/TestRunner/1.0.0/device" hx-target="#device_list" nunjucks-template="devices_dropdown"
                            hx-trigger="load">
                            <div id="device_list"></div>
                            <template id="devices_dropdown">
                                {% verbatim %}
                                {{ data }}
                                <select class="form-select form-select-sm col-sm-4">
                                    <option selected disabled>Select Device</option>
                                    {% for device in devices %}
                                    {{ device }}
                                    <option name="device_name" value="{{ device.device_id }}">{{ device.device_id }}</option>
                                    {% endfor %}
                                </select>
                                {% endverbatim %}
                            </template>
                        </div>
                    </div>
  • a

    abundant-spring-38265

    12/16/2022, 2:36 PM
    but for some reason i can't access elements: [{device_id: "00:00:5e:00:53:af", ip_address: "195.188.85.13", type: "router", status: "available"}]
  • r

    ripe-action-67367

    12/16/2022, 2:43 PM
    there is no devices field to iterate over
  • r

    ripe-action-67367

    12/16/2022, 2:46 PM
    i'm not sure how to refer to root object in nunjucks though
  • a

    abundant-spring-38265

    12/16/2022, 2:53 PM
    ah, i remember there's being a parameter you had to pass when list is unnamed
  • a

    abundant-spring-38265

    12/16/2022, 2:53 PM
    😮
  • a

    abundant-spring-38265

    12/16/2022, 3:13 PM
    hmm, in this example it's an unnamed list too: https://codepen.io/localhorst/pen/OJyepKG
  • a

    abundant-spring-38265

    12/16/2022, 3:13 PM
    :/
  • r

    ripe-action-67367

    12/16/2022, 3:14 PM
    see line 18 in JS in your example
  • a

    abundant-spring-38265

    12/16/2022, 3:18 PM
    😭 I want to avoid any JS hence HTMX 🙂
  • a

    abundant-spring-38265

    12/16/2022, 3:19 PM
    so only alternative is to encapsulate response in {'data': [{'device_id': 'blabla'}]}
  • m

    mysterious-toddler-20573

    12/16/2022, 3:50 PM
    10k stars: https://twitter.com/htmx_org/status/1603754308205510657
  • r

    ripe-action-67367

    12/16/2022, 3:51 PM
    there are other template engines that support iterating over root object
  • a

    abundant-spring-38265

    12/16/2022, 3:51 PM
    😮
  • a

    abundant-spring-38265

    12/16/2022, 3:52 PM
    thought nunjacks was best for json?
  • r

    ripe-action-67367

    12/16/2022, 3:52 PM
    Depends on your definition of best
  • a

    abundant-spring-38265

    12/16/2022, 3:52 PM
    well 🙂
  • r

    ripe-action-67367

    12/16/2022, 3:52 PM
    nunjacks is definitely very poverfull and has much more features
  • a

    abundant-spring-38265

    12/16/2022, 3:53 PM
    what would you recommend for something this basic though?
  • a

    abundant-spring-38265

    12/16/2022, 3:54 PM
    that's all i really need is to populate dropdown 🙂
  • r

    ripe-action-67367

    12/16/2022, 3:55 PM
    I personally used the other two, supported by the extension
  • r

    ripe-action-67367

    12/16/2022, 3:55 PM
    mustache and handlebars
  • r

    ripe-action-67367

    12/16/2022, 3:55 PM
    gimme a sec
1...952953954...1146Latest