Created
August 8, 2012 08:45
-
-
Save treasonx/3293539 to your computer and use it in GitHub Desktop.
Setting Data Attributes
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
//Incorrect | |
jQuery(document).ready(function () { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = "http://ardrone.swoop.com/js/spxw.js"; // use this for linked script | |
//The following will not properly set the required data attributes properly | |
script.attributes['data-domain'] = 'SW-XXXXXX-X'; | |
script.attributes['data-theme'] = 'red'; | |
script.attributes['data-serverbase']= 'http://ardrone.swoop.com/'; | |
document.body.appendChild(script); | |
}); | |
//Correct | |
jQuery(document).ready(function () { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = "http://ardrone.swoop.com/js/spxw.js"; // use this for linked script | |
script.setAttribute('data-domain', 'SW-XXXXXX-X'); | |
script.setAttribute('data-theme', 'red'); | |
script.setAttribute('data-serverbase', 'http://ardrone.swoop.com/'); | |
document.body.appendChild(script); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment