问题
I use jquery to load in sub-pages via ajax. The sub-page has some dojo widgets which work ok the first time. But subsequent loads I get Error: defineAlreadyDefined and the rest of the javascripts after this point is not run which means some key jquery instructions, e.g. UI layout. Can any one help as I have searched the web for this "Error: defineAlreadyDefined" of dojo and the best I came up with was it was addressed in dojo 1.6, however I am using 1.7.2 . I hope that I am doing something stupid as it is very frustrating as you would expect that dojo.js could be loaded many times by the user performing refresh etc. I should add that I tried placing the dojo.js in the main html page but then I received problems of dijit not found when loading the sub-page.
回答1:
dojo.js defines a global variable called define
. I'm fairly certain the error you're seeing comes from if you load dojo.js more than once and its to let you know that define
is already defined. Ideally you should just load dojo.js once.
回答2:
I could not resolve the actual error message and I believe its cause is buried within dojo initial load on a reload. However, to resolve the realigning of ui-layout panes I included myLayout.initContent("center")
in the ajax onComplete function.
来源:https://stackoverflow.com/questions/9784314/when-dojo-js-loaded-via-ajax-multiple-times-get-error-definealreadydefined