I'm new to Dojo world. I tried to create a custom dojo widget from scratch.The problem that I'm facing is the widget is not getting parsed. I see that postCreate
method of that widget is not getting called. The widget JS file is being downloaded from the server.
Here are the steps what I followed.
Created a JavaScript file CustomWidget.js in test folder.
dojo.provide('test.CustomWidget'); dojo.require('dijit._Widget'); dojo.declare('test.CustomWidget', dijit._Widget, { text: "Hello World", postCreate: function() { console.log(this.text+'text'); this.domNode.innerHTML=this.text; } });
In my jsp file,I imported test.CustomWidget using
dojo.require
.<script type="text/javascript"> dojo.require('test.CustomWidget'); dojo.addOnLoad(function(){ dojo.parser.parse("addFavorites"); }); </script> <div id='addFavorites' dojoType='test.CustomWidget'> </div>
I can see that CustomWidget.js file is being downloaded, but I don't see the console statement being printed. Can someone plese help me?