Skip to content

Commit 3f61bfc

Browse files
committed
Fixed toggle controls on added content permission role rows
1 parent 905d339 commit 3f61bfc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

resources/js/components/entity-permissions.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
22
* @extends {Component}
33
*/
4+
import {htmlToDom} from "../services/dom";
5+
46
class EntityPermissions {
57

68
setup() {
@@ -53,11 +55,8 @@ class EntityPermissions {
5355

5456
// Get and insert new row
5557
const resp = await window.$http.get(`/permissions/form-row/${this.entityType}/${roleId}`);
56-
const wrap = document.createElement('div');
57-
wrap.innerHTML = resp.data;
58-
const row = wrap.children[0];
58+
const row = htmlToDom(resp.data);
5959
this.roleContainer.append(row);
60-
window.components.init(row);
6160

6261
this.roleSelect.disabled = false;
6362
}

resources/js/services/dom.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,17 @@ export function removeLoading(element) {
117117
for (const el of loadingEls) {
118118
el.remove();
119119
}
120+
}
121+
122+
/**
123+
* Convert the given html data into a live DOM element.
124+
* Initiates any components defined in the data.
125+
* @param {String} html
126+
* @returns {Element}
127+
*/
128+
export function htmlToDom(html) {
129+
const wrap = document.createElement('div');
130+
wrap.innerHTML = html;
131+
window.components.init(wrap);
132+
return wrap.children[0];
120133
}

0 commit comments

Comments
 (0)