Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a page where the user can choose the images that will be shown in a slideshow. I am attempting to use mootools drag and drop and would like to use lightgallery.js.

How can I pass an array of dropped images into the dynamicEL?
Is there a way to load the images using the id/class of #cart.item?

Any help is greatly appreciated. And apologies in advance for being new at coding.

Here is a codepen that only seems to be slightly working [^]

What I have tried:

$(function() {


  jQuery('#dynamic').on('click', function() {
    var selected_image = [];
     jQuery( "#cart.item img" ).each(function() {
      var item1 = {
        src: $(this).find('img').attr('src'),
        thumb: $(this).find('img').attr('data-thumb'),
        subHtml: '<h4></h4>'
      };
       selected_image.push(item1);
    });


    jQuery(this).lightGallery({
      dynamic: true,
      dynamicEl: selected_image
    })
  });

   });



C#
jQuery.noConflict();
var drop = $('cart');
var dropFx = drop.effect('background-color', {wait: false}); // wait is needed so that to toggle the effect,
 
$$('.item').each(function(item){
 
	item.addEvent('mousedown', function(e) {
		e = new Event(e).stop();
 
		var clone = this.clone()
			.setStyles(this.getCoordinates()) // this returns an object with left/top/bottom/right, so its perfect
			.setStyles({'opacity': 0.7, 'position': 'absolute'})
			.addEvent('emptydrop', function() {
				this.remove();
				drop.removeEvents();
			}).inject(document.body);
 
		drop.addEvents({
			'drop': function() {
				drop.removeEvents();
				clone.remove();
				item.clone().inject(drop);
				dropFx.start('7389AE').chain(dropFx.start.pass('ffffff', dropFx));
			},
			'over': function() {
				dropFx.start('98B5C1');
			},
			'leave': function() {
				dropFx.start('ffffff');
			}
		});
 
		var drag = clone.makeDraggable({
			droppables: [drop]
		}); // this returns the dragged element
 
		drag.start(e); // start the event manual
	});
 
});
Posted
Updated 10-Nov-16 10:08am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900