I have a function I want to call when dynamically created content comes from ajax. This bit is working fine. I also want to call the function when the class .check_if_checked
changes (checkbox checked or radio changed, etc.). I have...
$('.check_if_checked').on('change', '#page-wrapper', function() {
activate_step_2_button();
});
function activate_step_2_button(){
//do stuff
}
The .on
will just NOT detect changes. If I put
$('.check_if_checked').on('change', '#page-wrapper', function() {
});
inside
function activate_step_2_button(){
//do stuff
}
then it detects ok...... but then I can't directly call the function from other places (there's not a change in that case).
Oh, and if I enter
$('.check_if_checked').on('change', '#page-wrapper', function() {
activate_step_2_button();
});
into the console everything works.
And yes, I read over JQuery function only works within a function already. This feels like a duplicate of that, but the solution there (and other similar solutions) are just not working.