Opened 10 years ago
Closed 10 years ago
#12736 closed defect (invalid)
AMD load callback in define(...) is not called in inline script
Reported by: | zhangyp | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | tbd |
Component: | Core | Version: | 1.6.0 |
Keywords: | Cc: | Rawld Gill | |
Blocked By: | Blocking: |
Description (last modified by )
If I use define method to load and declare module in inline javascript. The callback is never called. But if I use require(), the callback is successfully called. Here is my test case to reproduce the problem. (Also, if the javascript is externalized to a js file and introduced into HTML by <script> tag, it still does not work.)
<!DOCTYPE HTML> <html> <head> <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="async:false, parseOnLoad: false, mblHideAddressBar: false "></script> <script type="text/javascript"> require(["dojo"],function(){ console.log("successful callback in require."); }); define("test",["dojo"],function(){ console.log("successful call back in define."); }); </script> </head> <body> </body> </html>
Change History (4)
comment:1 Changed 10 years ago by
Cc: | rawld added |
---|---|
Description: | modified (diff) |
Resolution: | → invalid |
Status: | new → closed |
comment:2 Changed 10 years ago by
Cc: | Rawld Gill added; rawld removed |
---|
comment:3 Changed 10 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
I should have filed this bug as found in the trunk of 1.7 not 1.6. This is a simplified test case to show the callback of require works but callback in define does not work. If I put the define block to an external js file for example test.js and introduce that test.js in this html by <script type="text/javascript" src="test.js"></script> The call back in the define block is not called. Right now, it seems to me that I need to write following to explicitly declare that I need "test" in order to get the resource load and called? Originally, the script tag works. <script type="text/javascript">
require(test?);
</script> Also, I specified in djConfig async:false, will it make the resource load immediately?
comment:4 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
As I wrote above, AFAIK this is expected behavior.
What makes you think this is a bug? There's no reason to execute define's callback unless someone asks for the value, through a require call like: