Last active
December 15, 2015 02:49
-
-
Save eduardo-matos/5190377 to your computer and use it in GitHub Desktop.
load-css module in Dojo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'dojo/on', | |
'dojo/_base/window', | |
'dojo/dom-construct', | |
'dojo/Deferred' | |
], function ( | |
on, | |
win, | |
domConstruct, | |
Deferred | |
) { | |
'use strict'; | |
function loadCss (url) { | |
var deferred = new Deferred(); | |
var link = domConstruct.create('link', { | |
rel: 'stylesheet', | |
type: 'text/css', | |
href: url | |
}, win.body()); | |
on(link, 'load', function () { | |
deferred.resolve(); | |
}); | |
return deferred.promise; | |
} | |
return loadCss; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment