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

Feature request : add click event on ngx-dnd-container #8

Closed
ElodieBergonnier opened this issue Jun 2, 2017 · 2 comments
Closed

Feature request : add click event on ngx-dnd-container #8

ElodieBergonnier opened this issue Jun 2, 2017 · 2 comments

Comments

@ElodieBergonnier
Copy link

It would be nice to have a click event on container so we can capture the active item.

Here is an example of code from the demo where I added (click) event.

<ngx-dnd-container
            dropZone="builder-target"
            [model]="model.children"
            [removeOnSpill]="true"
            [template]="template"
            [droppableItemClass]="droppableItemClass"
            (click)="setActiveItem($event)"
            (drag)="log($event)"
            (drop)="log($event)"
            (over)="log($event)"
            (out)="log($event)"
            (remove)="log($event)">
@Hypercubed
Copy link
Contributor

While possible, my advice would be to handle that in the using the directives or item templates.

Using a template

<ngx-dnd-container [model]="items">
  <ng-template let-model="model">
    <div (click)="setActiveItem(model)">{{model.name}}</div>
  </ng-template>
</ngx-dnd-container>

In general I would recommend using the directives for anything more complex than a simple drag and drop lists.

Using directives

<div class="ngx-dnd-container" ngxDroppable [model]="items">
  <div
    class="ngx-dnd-item"
    ngxDraggable
    *ngFor="let item of items"
    (click)="setActiveItem(item)">{{item.name}}</div>
</div>

@Hypercubed
Copy link
Contributor

If you think this doesn't work fro some reason please reopen.

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

2 participants