1

I'm in Dojo 1.7, async loading.

I've got a contentpane that I populate via ajax with content. I want to use a uploader declaritively in this content - how do I require the uploader properly?

Let's say this is my server page I am using to generate my content that will be set as the contentpane:

<script>
require(["dojox/form/uploader/FileList",
    "dojox/form/uploader/plugins/Flash"]);
</script>

<center>
<input type="file" multiple="true" data-dojo-type="dojox.form.Uploader"
    data-dojo-props='
        label:"Foo My Bar!",
        url:"/tests/UploadFile.php",
        uploadOnSelect:"true"'/>
</center>
<br>
<div id="files" data-dojo-type="dojox.form.uploader.FileList"
            data-dojo-props='uploaderId:"uploader"'></div>

But this does not work: the widget classes are not found. I understand this is because the loader is in async mode, and apparently the parser is attempting to render the widgets before the require calls have completed.

So, question is, how to do this properly? If I put the require calls in the main page of the app, things work (including on widgets that are declaratively set in the main page).

mtyson
  • 8,196
  • 16
  • 66
  • 106

3 Answers3

1

It seems 'dojox/form/Uploader' is not loaded... is it required?

And you can parse contents any time you call dojo.parser.parse. If you want to execute a first parsing from your code, set "parseOnLoad : false" on dojo config, and call "dojo.parser.parse(dojo.body());".

rika-t
  • 91
  • 4
1

You need to put in require all widget modules you are referencing declaratively on the page:

require(["dojo/parser","dojox/form/Uploader","dojox/form/uploader/FileList"],
  function(parser){
    parser.parse()
});
Danubian Sailor
  • 1
  • 38
  • 145
  • 223
0

Have you tried using dojox/layout/ContentPane instead of the ContentPane in dijit? The ContentPane type in dojox is derived from the one in dijit by allows code to be run in the dynamic content. It also seems to load necessary widget references when parsing widgets in the content.

Josh G
  • 14,068
  • 7
  • 62
  • 74