title: Scope problem in JS: Uncaught TypeError: Object #<an Object> has no method 'createDocumentFragment'
body: <p>I'm trying to make instrument to simplify work with complex grids of <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs" rel="nofollow">jqGrid</a>, a function that could read schemes of grids, but looks like i lack JS skills for that )</p>
  
  <pre><code>function renderGridSystemRecursively(scheme, container){
  
  // CHILDREN
      if ('children' in scheme &amp;&amp; scheme.children.length &gt; 0) {
          scheme.prm.gridPrm.subGrid = true
          scheme.prm.gridPrm.subGridRowExpanded = function (expandedRowContainer_id, parent_dataitem_id) {
  
              var hiddenAtStart = (scheme.children.length &gt; 1) ? true : false
              for (var i in scheme.children) {
                  var child = scheme.children[i]
                  if ('scheme' in child) {
  
  // NEXT LINE CAUSES ERROR 
  // Uncaught TypeError: Object #&lt;an Object&gt; has no method 'createDocumentFragment'
                      var subcontainer = $('&lt;div style="float: left;"/&gt;',{id:expandedRowContainer_id+'_'+child.subId})
                      container.append(subcontainer)
  
                      child.scheme.hiddengrid = (child.scheme.hiddengrid == undefined) ? hiddenAtStart : child.scheme.hiddengrid
  
                      var self = $('#'+subcontainer.attr('id')+'_grid')
                      child.scheme.prm = child.scheme.prmInit(parent_dataitem_id, self)
                      child.scheme.prm.navMode = 'subgrid'
                      renderGridSystemRecursively(child.scheme, subcontainer)
                  }
              }
          }
      }
  //...
  
      renderGrid(scheme.prm, container, scheme.prm.navMode)
  }
  </code></pre>
  
  <p>Function definition is located in separate file, and is in global scope.
  Function called outside of ready(), but error accures inside of subGridRowExpanded event handler, so it looks like that i've messed up with closures, can't figure out how exactly.</p>
  
  <p>I don't use any other library except jquery.</p>