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

    ripe-action-67367

    11/04/2022, 9:24 AM
    Vue relies on virtual DOM that must be in sync with page DOM
  • g

    gorgeous-airport-54386

    11/04/2022, 9:25 AM
    it's easier to embed spa components in htmx fragments than the other way around
  • r

    ripe-action-67367

    11/04/2022, 9:25 AM
    htmx will break this parity and, as a result, vue will most likely behave unpredictably
  • r

    red-dinner-66239

    11/04/2022, 9:28 AM
    but what do you advise me to do?
  • g

    gorgeous-airport-54386

    11/04/2022, 9:32 AM
    you could watch the array you're looping over and call htmx.processNode when it changes
  • r

    red-dinner-66239

    11/04/2022, 9:59 AM
    Sorry, I didn't quite understand
  • r

    red-dinner-66239

    11/04/2022, 9:59 AM
    Can I show you my code?
  • r

    red-dinner-66239

    11/04/2022, 9:59 AM
    Copy code
    html
    
         <tr v-for="post in HubriseOrder" onclick="myFunction()" class="btnSelect tr-commande contenttableforpopup" hx-post="'{{ request.path }}?id=' + post.id" hx-target=".modal-body">
              <td data-label="N° de commande" >[[ post.id_order]]</td>
              <td data-label="Type de service">[[post.service_type]]</td>
              <td data-label="Prix">[[post.status]]</td>
          </tr>
  • g

    gorgeous-airport-54386

    11/04/2022, 9:59 AM
    are you using composition API or options API?
  • r

    red-dinner-66239

    11/04/2022, 10:00 AM
    from htmx ?
  • g

    gorgeous-airport-54386

    11/04/2022, 10:00 AM
    from vue
  • g

    gorgeous-airport-54386

    11/04/2022, 10:00 AM
    https://vuejs.org/guide/introduction.html#api-styles
  • r

    red-dinner-66239

    11/04/2022, 10:01 AM
    not that I know of, I just imported the script to run vue.Js
  • g

    gorgeous-airport-54386

    11/04/2022, 10:02 AM
    can you show where
    HubriseOrder
    is declared?
  • r

    red-dinner-66239

    11/04/2022, 10:02 AM
    I'm not expert in vue.js I just use it for a websocket
  • r

    red-dinner-66239

    11/04/2022, 10:04 AM
    Copy code
    js
          <script>
          vueApp = new Vue({
            el: "#app",
            delimiters: ["[[", "]]"],
            data() {
              return {
                HubriseOrder: [],
              };
            },
          });
    
          var ws = new WebSocket("ws://localhost:8000/ws/");
    
          ws.onopen = function (e) {
            ws.send(
              JSON.stringify({
                action: "list",
                request_id: new Date().getTime(),
              })
            );
          };
    
          ws.onmessage = function (e) {
            allData = JSON.parse(e.data);
            if (allData.action === "list") {
              vueApp.$data.HubriseOrder = allData.data;
              vueApp.$forceUpdate();
            } else if (allData.action === "create") {
              vueApp.$data.HubriseOrder.push(allData.data);
            }
          };
        </script>
  • g

    gorgeous-airport-54386

    11/04/2022, 10:04 AM
    ok, this is options api
  • r

    red-dinner-66239

    11/04/2022, 10:13 AM
    yes šŸ˜…
  • g

    gorgeous-airport-54386

    11/04/2022, 10:14 AM
    Copy code
    js
    vueApp = new Vue({
      el: "#app",
      delimiters: ["[[", "]]"],
      data() {
        return {
          HubriseOrder: [],
        };
      },
      watch: {
        HubriseOrder(newOrder, oldOrder) {
          htmx.processNode(this.$refs.table);
        }
    });
  • g

    gorgeous-airport-54386

    11/04/2022, 10:14 AM
    and add
    ref=table
    to your table
  • r

    red-dinner-66239

    11/04/2022, 10:18 AM
    I'm out on an important errand, as soon as I get home I'll test it, thanks a lot!
  • r

    red-dinner-66239

    11/04/2022, 1:26 PM
    I have modified with your code but it does not work error
    Copy code
    Uncaught SyntaxError: Unexpected token ')' (at commande:227:18)
  • r

    red-dinner-66239

    11/04/2022, 1:27 PM
    ah it misses
    Copy code
    }
  • r

    red-dinner-66239

    11/04/2022, 1:29 PM
    i have this error
    Copy code
    ReferenceError: htmx is not defined
        at Cn.HubriseOrder (commande:225:23)
        at Be (vue@2.6.14:6:11394)
        at pn.run (vue@2.6.14:6:27888)
        at ln (vue@2.6.14:6:25859)
        at Array.<anonymous> (vue@2.6.14:6:12476)
        at We (vue@2.6.14:6:11877)
  • r

    red-dinner-66239

    11/04/2022, 1:57 PM
    I don't see where to define it @gorgeous-airport-54386
  • g

    gorgeous-airport-54386

    11/04/2022, 1:57 PM
    how did you import htmx?
  • g

    gorgeous-airport-54386

    11/04/2022, 1:57 PM
    you need that to be before your vue code
  • r

    red-dinner-66239

    11/04/2022, 2:04 PM
    ok I fixed it but now I have this new error```htmx.processNode is not a function```
  • r

    red-dinner-66239

    11/04/2022, 2:10 PM
    yet I have well defined htmx @gorgeous-airport-54386
  • g

    gorgeous-airport-54386

    11/04/2022, 2:10 PM
    sorry, it's just
    process
1...890891892...1146Latest