Joined July 2016
·

Guim

Posted to Lazy carousel in bootstrap over 1 year ago

i found 2 solutions :
First, you have to put this code just before :
jQuery.fn.extend({
renameAttr: function( name, newName, removeData ) {
var val;
return this.each(function() {
val = jQuery.attr( this, name );
jQuery.attr( this, newName, val );
jQuery.removeAttr( this, name );
// remove original data
if (removeData !== false){
jQuery.removeData( this, name.replace('data-','') );
}
});
}
});
- if you want to load picture with the carousel you add this after :
$(function() {
return $(".carousel").on("slide.bs.carousel", function(ev) {
$(this).find('.loadClick').renameAttr('data-src', 'src' );
});
- if you want to load picture with the modal you add this after :
$(function() {
$('.modal').on("shown.bs.modal", function (e) {
$(this).find('img').renameAttr('data-src', 'src' );
});
});

Posted to Lazy carousel in bootstrap over 1 year ago

Your code is really interesting.
In my case, each item of the carousel have more than one image.
So, with this code, instead of having all my images, I just had the first that is repeated. So, if i have 10 images in one page of the carousel, all are the same.
Do you have a solution for that ?
Thanks :)

Achievements
1 Karma
0 Total ProTip Views