having trouble with events on dynamically added objects (again)
Again I'm struggling with events on dynamically added elements.
is there something I'm missing? The code works fine for elements that exist on startup..
- $(".product-like-wrap").on("click", ".symbol-circle", function () {
- C.Ajax.Invoke(null, "Api", "LikePicture", { id: id }, {}, "POST", function (data) {
- let $wrap = $caller.closest(".product-like-wrap");
- $($wrap).find(".check-symbol").removeClass("hide");
- $($wrap).find(".symbol-circle").addClass("hide");
- $($wrap).find(".exists > .inner > .count").html(data.length);
- $($wrap).find(".exists").removeClass("hide");
- });
- });
the like-wrap div below is static, but all content is added after startup.
- <div class="like-wrap">
- <div class="product-like-wrap flex-center-center">
- <span class="check-symbol hide" title="Du har likt bilde"><i class="fas fa-check"></i></span>
- <div class="symbol-circle align-center " title="Lik bilde" data-id="112">
- <i class="fas fa-thumbs-up symbol" data-id="112"></i>
- </div>
- <span class="exists hide"><span class="inner"><span class="separator">/</span><span class="count">0</span></span></span>
- </div>
- </div>
--------------
Just so we're clear - you need a hero?