I have something similar to this:
$('.new-post').on('click', function(e) {
  e.preventDefault();
  $.ajax({
    url: '/somehting'
    data: {my data},
    ...etc,
    success: function(data) {
      $.get('template.html', function(h) {
        var el = $(h);
        el.find('items').text('texts...');
        el.appendTo('.myElement');
      });
    }
  });
});
I'm posting a new post using ajax and I wish that after it has been saved to the server it is appended to the existing posts list.
It works fine but if I click on links that I append using the html template nothing seems to work...
Probably I used a wrong strategy to do that, so here I need a bit of your help.
I used $.get within the success method in order to get an html template where to insert new post data to append. I know that $.get is async but for some reason it doesn't work until I don't refresh the page...
EDIT (HTML)
<li>
  <h2></h2>
  <p></p>
  <ul class='actions'>
    <li><a href='link to the post'></a>
    <li><a href='#' data-modal='comment-modal'>Comment</a>
  </ul>
</li>
 
     
    