From 53e5f10c6ba29e78abeec1298be49a1bb43e3d7f Mon Sep 17 00:00:00 2001 From: Zack Barett Date: Mon, 7 Dec 2020 06:54:03 -0600 Subject: [PATCH] Add new Events to Custom View Docs (#746) --- .../custom-ui/lovelace-custom-view.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/frontend/custom-ui/lovelace-custom-view.md b/docs/frontend/custom-ui/lovelace-custom-view.md index dae86b9c..e284d8c6 100644 --- a/docs/frontend/custom-ui/lovelace-custom-view.md +++ b/docs/frontend/custom-ui/lovelace-custom-view.md @@ -73,3 +73,25 @@ If your view requires data to persist at a card level, there is a `layout` in th width: 54px entity: weather.my_weather ``` + +## Edit, Delete, or Add a Card + +To call the core frontend dialogs to edit, delete or add a card, you can simply call these three events: + +``` +Event: "ll-delete-card" +Detail: { path: [number] | [number, number] } + +Event: "ll-edit-card" +Detail: { path: [number] | [number, number] } + +Event: "ll-add-card" +Detail: none +``` + +To call an event, you can use: + +```js +// Delete 4th card in the current view +this.dispatchEvent(new Event("ll-edit-card", { detail: { path: [3] } })) // this refers to the card element +```