I tried to get rid of jQuery, but document.getElementById("content").innerHTML = html doesn't seem to work for some reason, even though it does set the HTML. But I need jQuery for the larger project anyway, so that's OK...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks! This is what it looks like in proper ES6 (some parts omitted):
let vue_components = { loadComponents : function ( components ) { return Promise.all ( components.map ( component => this.loadComponent(component) ) ) ; } , loadComponent ( component ) { let id = this.getComponentID ( component ) ; if ( $('#'+id).length > 0 ) return Promise.resolve(42) ; // Already loaded/loading $('body').append($("").attr({id:id}).css({display:'none'}));
return fetch ( this.getComponentURL(component) )
.then ( (response) => response.text() )
.then ( (html) => $('#'+id).html(html) )
}
}
I tried to get rid of jQuery, but
document.getElementById("content").innerHTML = htmldoesn't seem to work for some reason, even though it does set the HTML. But I need jQuery for the larger project anyway, so that's OK...