Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elements dynamically #194

Open
nalancer08 opened this issue Jan 12, 2017 · 0 comments
Open

Add elements dynamically #194

nalancer08 opened this issue Jan 12, 2017 · 0 comments

Comments

@nalancer08
Copy link

Hi, i had probed your plugin, and it's very cool, but i adding elements in DOM dinamically, and in this point i bind the element with prep, and it works very well, but when i drag a element only takes the functions of last element inserted, in this case the "drag function", here my code:

`$('.tab_bar').on('click', function(e){

		e.preventDefault();

		var el = $(this);

		// el.addClass('hide');
		$('.screen .tab_screen').append('<div class="item tab_item item_' + cont +'"></div>');

		// Create the logic object
		var tab = obj.generateNewElement('tabBar');
		var la = '.item_' + cont;
		obj.screenComponents.tabBar = tab;
		cont = cont + 1;

		$(la).pep({

			droppable: '.tab_screen',
			constrainTo: '.screen',
		 	drag: function(ev, obj) {
		 		// console.log(obj);
		 		var item = $('.tab_item');
		 		var inspector = $('.inspector');

		 		//console.log($('.tab_item').position());
		 		var lala = '.opts';
		 		$(lala).remove();

		 		inspector.append('<div class="opts"> <p>Width: ' + item.width() + 
					'</p> <br> <p>Height: ' + item.height() +
					'</p> <br> <p>X: ' + item.position().left + 
					'</p> <br> <p>Y: ' + item.position().top + '</p> </div>'
				);
		  	}
		});
	});`
@briangonzalez briangonzalez changed the title Add elements dinamically Add elements dynamically Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant