I have a DOM like this:
<div class="inner-content">
<div class="catalogue" style="display: none;">
<div class="wrapper">
<!-- some dom here -->
<button type="button" id="updateCatalogue">
</div>
<span class="addNewRow" data-row="1">add new row</span>
</div>
I also have a JS-function which triggers correctly, when clicking "click new row". Have a look here:
$('.addNewRow').click(function() {
// determine closest wrapper
var wrapper = $(this).closest(".questions");
var kategorieId = $(this).data("row");
// add another row
$("<div class='question_wrapper'><input type='text' class='textinput_questions new_question' data-category='"+kategorieId+"' name='new_question["+kategorieId+"][]'><input type='checkbox' class='radioinput' style='margin-left: 6px !important;' name='new_questionActive[]'>").insertAfter(".question_wrapper:last");
});
This code works perfectly fine when I open my site and navigate manually to the DIV I'm currently in. Worth mentioning, I'm doing a bit ajax-stuff, which I guess is part of the problem:
$('#updateCatalogue').click(function() {
// inserting stuff
$('.new_question').each(function() {
data = "some data";
$.ajax({
url: "my-file.asp",
type: "GET",
data: data,
success: function(response) {
console.log(question);
// reload the frame afterwards
$(".inner-content").load(location.href + " #catalogue");
}
});
});
});
The part in the updateCatalogue
-function is processed correctly and the code inside my-file.asp
is doing its job as well. But as soon as the page "reloads", I can't click on "add new row" anymore... or more like, it doesn't do anything after that. No JS errors in my console.
Since I'm reloading the whole page, I should have access to everything, right?
Sidenote: These functions are in $(document).ready() if this is important for that
These elements are not dynamically created (I guess), since the site is reloaded, even though trough an ajax-call