Closed chizzycrusty closed 7 years ago
Can you be more specific on what the problem is? If you mean behaviors that have been defined for DOM elements that are introduced into the DOM when new content is loaded, then you will have to redefine those behaviors on the new elements using the callback
option. Or you can you use event delegation.
Yes, this is my problem, but I finally managed to load most of my script back with the event delegation (basically boostrap tabs collapse and showing modal). But I still have one problem. I'm using this package for a rating system: https://github.com/kartik-v/bootstrap-star-rating and I can't figure how to change this so that jQuery also load with the rating. I tried calling back jQuery like this:
$(function() {
$('.news-feed').jscroll({
autoTrigger: true,
loadingHtml: '<img class="center-block" src="/img/loading.gif" alt="Loading..." />',
padding: 0,
nextSelector: '.pagination li.active + li a',
contentSelector: 'div.news-feed',
callback: function() {
$('ul.pagination').remove();
$.getScript(urljQuery, function() {
console.log('test');
});
}
});
});
and also with ajax:
$.ajax({
type:'GET',
url: urljQuery,
dataType: "script"
});
It seems to load it as I get the console log but my ratings still don't show up.
Nevermind, I had to callback my rating script too. Thanks for you help.
Hello,
I use this plugin on a Laravel 5.4 project, the problem is that when new posts are loaded, jQuery doesn't work anymore in the posts loaded with the plugin as it works with the posts initially loaded.
Any idea of how I can fix that?