Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  22] [ 6]  / answers: 1 / hits: 39392  / 12 Years ago, mon, may 7, 2012, 12:00:00

I am trying to learn how to use require.js. So I made an HTML page with the following tags in the body.



<script type=text/javascript data-main=../js/shirt src=../js/require.js></script>
<script type=text/javascript>
alert(Shirt color is + shirt.color);
</script>


The ../js/shirt.js has the following code



define({
color: black,
size : large
});


How can I use this simple value pairs in my html?


More From » requirejs

 Answers
4

the contents of the main file should be a require call. for example, you have a values.js module containing:



define({
color: black,
size : large
});


in your main file (shirt.js), load the values.js as a dependency (assuming they are in the same directory):



require(['values'],function(values){
//values.color
//values.size
});

[#85734] Sunday, May 6, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
patienceannel

Total Points: 674
Total Questions: 101
Total Answers: 101

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
patienceannel questions
Fri, Mar 11, 22, 00:00, 2 Years ago
Tue, Oct 20, 20, 00:00, 4 Years ago
Wed, Jul 24, 19, 00:00, 5 Years ago
;