Reputation:
I think the source of my issue is the fact that I'm using ng-repeat, so I won't detail the rest too much but feel free to ask for precisions.
So, yes, I'm using ng-repeat to repeat a certain number of div stocked in an array.
When I create a new div and add it to the array...
var newDiv = document.createElement('div');
$scope.arrayDiv.push(newDiv);
...I also create a button (well, I use an image actually) and I append it to the div.
var newButton = document.createElement('img');
newButton.style="position: absolute; top: 6px; left: 16px; z-index: 9999;";
newButton.onclick=function() {
//delete the parentNode
}
newDiv.appendChild(newButton);
This button is in fact a close button and is used to delete the div containing it. So far so good, but here's my issue :
The close button only appears on the first div, and not on the others. However, the button is correctly closing the div one after the other. So this lead me to thought that the buttons are superposed.
Not sure I made myself clear, sorry. Here's the ng-repeat by the way :
<div id='main_chart_div' ng-repeat="x in arrayDiv" value={{x}}></div>
Upvotes: 1
Views: 52
Reputation: 1364
Make sure your newDiv
has relative position. If not, the position of the newButton
will be relative to the closest parent with a relative position.
Upvotes: 1