{"comment":{"created_at":"2011-10-21T06:27:57Z","body":"Thank you John. I was aware of order! However, it seems not applicable to my situation. I have a collection of apps that are organized in a family tree. Javascript modules are associated with the nodes, apps with leaves. An app requires all modules between the leaf where it sits and the root of the tree. Modules need be loaded in order (from root to leaf). E.g., the root may contain jquery while code at the other nodes depends on it. Sadly, none of my codefiles are written as modules - it is all plain old javascript. New code will be different, but that is how it is. Oh, and any of these modules will consist of multiple files - otherwise the whole problem would fold down to file ordering.\r\nAs I understood, order! affects the (plain javascript) files in a module - it cannot be used to order modules. \r\n\r\nI've experimented with the order of the requirements in the module statement. I've tried to 'chain' the modules between leaf and root (make the root a requirement for level one nodes, level one nodes a requirement for level two and so on). However, in the end it doesn't give the right behaviour. I am beginning to realize that the A in AMD carries a lot of meaning ;-)\r\n\r\nSo that is why I tried .next - it seems perfectly fit for my purposes. I might try nesting curl statements (a curl statement in the callback of another) but I can well imagine the kind of problems that might run into.\r\n\r\nBut I will look into the $(document).ready() statements. I've used a lot of them. Maybe that's where the problem is. \r\n\r\nAs a question: can I rightly infer the order of loading that is picked by Curl from the order of script statements inserted? That is, the earlier scripts are at the bottom, last script is the top one? ","updated_at":"2011-10-21T06:27:57Z","url":"https://api.github.com/repos/unscriptable/curl/issues/comments/2478170","id":2478170,"user":{"gravatar_id":"376373ebcfaaa430f9f1bc8380c3ec12","avatar_url":"https://secure.gravatar.com/avatar/376373ebcfaaa430f9f1bc8380c3ec12?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/joopringelberg","id":1141656,"login":"joopringelberg"}},"action":"created","issue":{"number":29,"created_at":"2011-10-20T20:11:50Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"I may not understand the intended meaning of the .next statement. However, I am trying to do the following: stage loading of files in tranches before the main code executes.\r\n\r\nFile testNext.html:\r\n\r\n    <head>\r\n        <title></title>\r\n        <script type=\"text/javascript\" id=\"curlConfig\">\r\n            curl = {\r\n            \tpaths: {\r\n            \t    curl: '/sharedJs/unscriptable-curl-5ac0fcd/src/curl/',\r\n            \t},\r\n            \tjsPrefetch: true\r\n            };\r\n        </script>\r\n        <script src=\"/sharedJs/unscriptable-curl-5ac0fcd/src/curl.js\" type=\"text/javascript\"> </script>\r\n        <script type=\"text/javascript\">\r\n            var steps = 0;\r\n            curl([ 'js!sharedJs/jquery.js' ])\r\n            .next([ 'js!stepOne.js' ], function(){ steps = steps+1; })\r\n            .next([ 'js!stepTwo.js' ], function(){ steps = steps+2; })\r\n            .then( function()\r\n                    {\r\n                        $(document).ready( function(){\r\n                                                        alert( steps );\r\n                                                        testOne();\r\n                                                        testTwo();\r\n                                                     });\r\n                    }\r\n                    ,function(){alert(\"something wrong\")});\r\n        \t\r\n        </script>\r\n    </head>\r\n    <body>\r\n    </body>\r\n\r\nstepOne.js:\r\nvar testOne;\r\n\r\n$(document).ready(function()\r\n{\r\n\ttestOne = function() { $( 'body' ).append(\"&lt;p&gt;Test One!&lt;/p&gt;\") }\r\n});\r\n\r\nstepTwo.js:\r\nvar testTwo;\r\n\r\n$(document).ready(function()\r\n{\r\n\ttestTwo = function() { $( 'body' ).append(\"&lt;p&gt;Test Two!&lt;/p&gt;\") }\r\n});\r\n\r\nOn loading the page, an alert box appears saying \"2\". The console shows \"testTwo is not defined\". Inspecting the page shows that a script element has been made for stepOne.js, but not for stepTwo.js. So it looks as if the requirement for the first .next statement has been fulfilled, but its callback is NOT executed; and the requirement for the second .next statement has not been fulfilled, but its callback has been executed.\r\nThanks,\r\nJoop","comments":2,"title":"issue with multiple .next statements","updated_at":"2011-10-21T06:27:57Z","url":"https://api.github.com/repos/unscriptable/curl/issues/29","id":2008896,"assignee":{"gravatar_id":"4a1e2bec5440c80c54bf76fc72164d7c","avatar_url":"https://secure.gravatar.com/avatar/4a1e2bec5440c80c54bf76fc72164d7c?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/unscriptable","id":46133,"login":"unscriptable"},"milestone":null,"closed_at":null,"user":{"gravatar_id":"376373ebcfaaa430f9f1bc8380c3ec12","avatar_url":"https://secure.gravatar.com/avatar/376373ebcfaaa430f9f1bc8380c3ec12?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/joopringelberg","id":1141656,"login":"joopringelberg"},"html_url":"https://github.com/unscriptable/curl/issues/29","labels":[],"state":"open"},"legacy":{"issue_id":2008896,"comment_id":2478170}}