When the tobeclicked
list is clicked it takes the data from that and pastes in the find empty list. Where it actually needs to find an empty list and update it. Values and list will have images in the real. So when image is clicked it finds empty list and clones there. I can't change the structure of empty list since it will have empty borders of size of image to be cloned. So user can know where he is adding.
HTML :
<div ng-app='myModule'>
<div class="tobeclicked">
<ul>
<li thisclicked data-value="img1">img 1</li>
<li thisclicked data-value="img2">img 2</li>
</ul>
</div>
<br>
<div class="find-empty">
<ul>
<li class="empty" data-value=""></li>
<li class="empty" data-value=""></li>
</ul>
</div>
</div>
JS
var myModule = angular.module('myModule', []);
myModule.directive("thisclicked", function () {
var thisclicked = function(scope,element,attrs) {
element.bind('click',function(){
var empty = $('.find-empty').find('.empty').first();
empty.html(element.html());
empty.attr('data-value',attrs.value);
empty.removeClass('empty');
});
};
return thisclicked;
});
Fiddle (http://jsfiddle.net/CQzu5/) is rough demo of what I want to do. Hopefully there is an angular way to do the same. (Note the fiddle is not the actual code just the example of what I want to do. Actual code has directive calling controller so data is basically fetched in a controller. I am not sure if this a correct way to do this but I'm open to suggestion.
This images should help too (real application):