Skip to content

Commit 8b0fd1b

Browse files
committed
feat: action to remove element(cloned template)
1 parent 91b0c6a commit 8b0fd1b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/*globals CustomEvent*/
2+
import action from '@cocreate/action';
13

2-
// import action from '@cocreate/action';
34

45
const CoCreateRender = {
56

@@ -177,6 +178,22 @@ const CoCreateRender = {
177178

178179
}
179180

181+
function removeElement(btn) {
182+
let element = btn.closest('[templateid]');
183+
if (element)
184+
element.remove();
185+
document.dispatchEvent(new CustomEvent('removeElement', {detail: {}}));
186+
}
187+
188+
action.init({
189+
action: "removeElement",
190+
endEvent: "removeElement",
191+
callback: (btn, data) => {
192+
removeElement(btn);
193+
}
194+
});
195+
196+
180197
// function renderKey(element) {
181198
// const container = element.closest("form") || document;
182199
// let data = form.getFormData(this.id, 'renderKey', container);

0 commit comments

Comments
 (0)