mardi 23 décembre 2014

alert box not popping out when using requirejs


I am new to require js and have been looking online for tutorials but do not really understand them.


I have placed all my jquery and require js in the same folder as my html file.


Test.html



<html>
<head>
<script data-main = "main" src = "require.js" type = "text/javascript"></script>

</head>
<body> testing </body>
</html>


Main.js (require main file)



(function()
{
requirejs.config(
{
paths: {
'jquery': 'jquery-2.1.3.min'
}
};
require(
['test']
function(alert){
alert.doc();
}
)
})();


test.js



define('alert', ['jquery']
function($){
var msg = $(document).ready(function(){
alert('i am just learning');
});

return {msg:msg};

});


am i doing something wrongly? The code does not run at all. at least for the javascript component





Aucun commentaire:

Enregistrer un commentaire