Can't use .replaceWith() second time. How can I replace it?

Viewed 56

guys! I need to replace .replaceWith() with something similar because .replaceWith() can't be called twice on the same element. I tried to use .html() and .empty().append(), but none of them working.

This is the block of code:

      context["comments"] = comments;
      var ratingTemplate = Handlebars.templates["comment_rating"];
      var template = Handlebars.templates["show_comments"];
      Handlebars.registerPartial("comment_rating", ratingTemplate);
      Handlebars.registerPartial("show_comments", template);
      Handlebars.registerHelper(handlebarsHelpers);
      $("#load-comment-section").hide();
      $("#comment-section")
        .replaceWith(template(context))
        .promise()
        .done(on_comment_section_load());

What would be the best approach? Thanks in advance! :)

0 Answers
Related