Skip to content

Commit

Permalink
Fixed #1583
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Dec 13, 2016
1 parent 02bd74e commit 3681325
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/contextmenu/contextmenu.ts
Expand Up @@ -116,6 +116,8 @@ export class ContextMenu implements AfterViewInit,OnDestroy {

@Input() styleClass: string;

@Input() appendTo: any;

visible: boolean;

container: any;
Expand All @@ -139,6 +141,13 @@ export class ContextMenu implements AfterViewInit,OnDestroy {
event.preventDefault();
});
}

if(this.appendTo) {
if(this.appendTo === 'body')
document.body.appendChild(this.el.nativeElement);
else
this.domHandler.appendChild(this.el.nativeElement, this.appendTo);
}
}

show(event?: MouseEvent) {
Expand Down Expand Up @@ -219,6 +228,10 @@ export class ContextMenu implements AfterViewInit,OnDestroy {
this.unsubscribe(item);
}
}

if(this.appendTo) {
this.el.nativeElement.appendChild(this.container);
}
}

}
Expand Down
6 changes: 6 additions & 0 deletions showcase/demo/contextmenu/contextmenudemo.html
Expand Up @@ -105,6 +105,12 @@ <h3>Attributes</h3>
<td>null</td>
<td>Style class of the component.</td>
</tr>
<tr>
<td>appendTo</td>
<td>any</td>
<td>null</td>
<td>Target element to attach the overlay, valid values are "body" or a local template variable of another element.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 3681325

Please sign in to comment.