Skip to content

load_css #29

@gbrault

Description

@gbrault

I had an issue with using load_css in the back-end, providing an url for the resource.
I did the following workaround

  • adding a front-end function loadResource
  • using it from the front-end
function loadResource(url,kind, callback){
    var res = null;
    if (kind == 'script'){
        var found = document.querySelector('[src="'+url+'"]');
        if (found == null){
            res = document.createElement(kind);
            res.type = "text/javascript";
            res.src = url;
        }
    } else if (kind == 'link'){
        var found = document.querySelector('[href="'+url+'"]');
        if (found == null){
            res = document.createElement(kind);
            res.rel = "stylesheet";
            res.href = url;
        }
    }
    if (res == null){
            if (callback == null ){
                isloaded(url);
            } else {
                callback(url);
            }                
    } else {
        res.onload = function(){
            if (callback == null ){
                isloaded(url);
            } else {
                callback(url);
            }
        };
        document.getElementsByTagName("head")[0].appendChild(res);     
    }
}
loadResource('https://unpkg.com/bpmn-js@8.8.2/dist/assets/diagram-js.css','link',null);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions