title: Dynamically adding dijit on button click programatically...how?
body: <p>I've got a problem with another dojo enabled form that I am working on.  A user can enter details onto the page by entering the data using a dialog box, which in turn updates the database and then displays the user data entered on to the form.  </p>
  
  <p>Each element added consist of 2 x Validation Text boxes 1 x FilteringSelect. When it's added to the page they are added as simply text boxes.</p>
  
  <p>I've tried just adding as standard strings but that means the dojo.parse() does not run on the code.  I've also tried programmatically adding the elements but that just displays the element object as a string to the page.  So far I have:</p>
  
  <pre><code>var xhrArgs = {
      url: url,
      handleAs: "text",
      preventCache: true,
      load: function(data){
  
          var idResult = parseInt(data);
  
          if(idResult &gt; 0){
  
  
              var divStr = '&lt;div id="employ_' + idResult + '" style="float:left;width:100%;"&gt;' +
               '&lt;table width="300"&gt;' +
                  '&lt;tr&gt;' +
                      '&lt;td height="29"&gt;&lt;Strong&gt;' +
                              '&lt;input type="text" dojoType="dijit.form.ValidationTextBox ' + 
                                  'change="markEmploymentForUpdate(); ' +
                                  'id="cmpy_'+ idResult +'" '+
                                  'required="true" ' +
                                  'promptMessage="Please enter a valid company name" ' +
                                  'invalidMessage="please enter a valid company name" ' +
                                  'trim="true"' +
                                  'value="'+ companyname +'"/&gt;' +
                      '&lt;/td&gt;' +
                      '&lt;td height="29"&gt;&lt;input dojoType="dijit.form.FilteringSelect" store="rolestore" searchAttr="name" name="role" onchange="markEmploymentForUpdate();" id="roleInput_'+ idResult +'" value="'+ jobrole +'" &gt;&lt;/td&gt;' +
                      '&lt;td height="29"&gt;' +
                          '&lt;input type="text" dojoType="dijit.form.ValidationTextBox" onchange="markEmploymentForUpdate();"' +
                              'id="jtitle_'+ idResult + '"' +
                              'required="true"' +
                              'promptMessage="Please enter your job title"' +
                              'invalidMessage="Please enter your job title"' +
                              'value="'+ jobtitle + '"/&gt;' +
                      '&lt;/td&gt;' +
                      '&lt;td height="29"&gt;&lt;img src="/images/site/msg/small/msg-remove-small.png" border="0" onmouseover="this.style.cursor=\'pointer\';" onclick="removeEmployer(\'employ_'+ idResult +'\', '+ idResult +')" /&gt;&lt;/td&gt;' +
                  '&lt;/tr&gt;' +
              '&lt;/table&gt;' +
          '&lt;/div&gt;'; 
  
              dijit.byId('companydetails').hide();
              dijit.byId('employername').setValue('');
              dijit.byId('jobtitle').setValue('');
              dijit.byId('jobrole').setValue('');
  
              dojo.byId('data-table').innerHTML += divStr;
  
              dojo.byId('companydetails').hide(); 
  
  
          }else{
  
              dojo.byId('add-error').innerHTML = '&lt;div class="error"&gt;Unable to process your request. Please try again.&lt;/div&gt;';
  
          }
  
  
  
      }       
  };
  
  var deferred = dojo.xhrGet(xhrArgs);
  </code></pre>
  
  <p>This is displaying text boxes as the dojo.parse isn't running on this. If I replace the ValidationTextBox with:</p>
  
  <pre><code>var textbox = new dijit.form.ValidationTextBox({
     id:"cmpy_" + idResult,
     required:true,
     trim:true,
     "change":"markEmploymentForUpdate();",
     promptMessage:"Please enter a valid company name",
     value:companyname
  });
  </code></pre>
  
  <p>I just get the object printed to the page.</p>
  
  <p>Any ideas how I can added this to my page and maintain the dojo component rather than it defaulting to a text box?</p>
  
  <p>Many thanks.</p>