0

For grabbing a value from a li tag and putting into an input filed i use the data-value. My list tags look like this:

<li class="set-value" data-value="test">grab value</li>

The js:

$(".set-value").click(function(){           
       var s = this.dataset.value;                         
       $(".set-input").val(s);
});

My input field looks like this:

<input class="set-input" type="text" value="" />

When click on grab value it puts test in to the input.! That works fine! When i do submit the value, i use an ajax call. After the ajax call, all li tags are dynamically reloaded. Problem is: when i click again on test, sending the value to the input field does not work anymore. After a hard refresh, it DOES work again. I checked the following after the ajax:

  • jquery core file is still loaded
  • the js is still in the DOM

So why it does not work anymore for the second time?

Jack Maessen
  • 1,780
  • 4
  • 19
  • 51

0 Answers0