I've got a problem with .on()
.
I have multiple form-elements (forms with class="remember"
), also I add another one form.remember
using AJAX.
So, I want it to handle submit event something like:
$('form.remember').on('submit',function(){...})
but form added with AJAX doesn't work with it.
Where is the problem? Is it a bug?
You need to delegate event to the document level
$(document).on('submit','form.remember',function(){
// code
});
$('form.remember').on('submit'
work same as $('form.remember').submit(
but when you use $(document).on('submit','form.remember'
then it will also work for the DOM added later.