I have a jQuery plugin that I am using:
$(document).ready(function(){
$('.elements').fancyPlugin();
});
This works great until I start adding new elements:
$.get('ajax.html', function(data){
$('#container').html(data);
});
I could call the plugin function again like this:
$.get('ajax.html', function(data){
$('#container').html(data).find('.elements').fancyPlugin();
});
...except that the AJAX is happening inside another jQuery plugin that shouldn't have to know about the fancyPlugin()
.
How can I apply this plugin to all current and future elements?