I have a <div> with id="modal" dynamically generated using the jQuery load() method:
$('#modal').load('handlers/word.edit.php');
word.edit.php contains several input elements that are loaded into the modal <div> .
Using the jQuery keyup method, I can capture the input values ββafter the event fires, but when the elements are dynamically added to the modal div, the event when llonger does not start when the user enters their text.
Which jQuery method supports handling events caused by dynamically generated elements?
Code for creating new input elements:
$('#add').click(function() { $('<input id="'+i+'" type="text" name="translations' + i + '" />') .appendTo('#modal');
Code to capture custom values:
$('input').keyup(function() { handler = $(this).val(); name = $(this).attr('name');
This second block of code works for the original elements, but it is not triggered by new dynamically generated elements.
javascript jquery
redbull330 10 Oct '12 at 23:24 2012-10-10 23:24
source share