File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 11/**
22 * @extends {Component }
33 */
4+ import { htmlToDom } from "../services/dom" ;
5+
46class 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 }
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments