title: jsTree custom contextmenu not filtering based on type folder/file
body: <p>I am trying to configure a custom context menu for jsTree. I want files to have two options [Rename, Delete] and I want folders to have one option [Create]</p>
  
  <p>The below code seems correct as described here: <a href="https://stackoverflow.com/questions/4559543/configuring-jstree-right-click-contextmenu-for-different-node-types">Configuring jstree right-click contextmenu for different node types</a></p>
  
  <p>However this does not seem to work, there are two problems. </p>
  
  <ol>
  <li>Both context menus display the options [Rename, Delete]  </li>
  <li>Choosing either option
  causes the error: Uncaught TypeError: undefined is not a function</li>
  </ol>
  
  <p><img src="https://i.stack.imgur.com/Jvyh0.png" alt="enter image description here"></p>
  
  <p>What am I doing wrong?
  Edit: here is a <a href="http://jsfiddle.net/7xpbf/" rel="nofollow noreferrer">fiddle</a></p>
  
  <pre><code>$( document ).ready(function() {
      function customMenu(node) {
          // The default set of all items
          var items = {
              createItem: { // The "create" menu item
                  label: "Create",
                  action: function () {
                      this.create(node);
                  }
              },
              renameItem: { // The "rename" menu item
                  label: "Rename",
                  action: function () {
                      this.rename(node);
                  }
              },
              deleteItem: { // The "delete" menu item
                  label: "Delete",
                  action: function () {
                      this.remove(node);
                  }
              }
          };
  
          if ($(node).hasClass("folder") || $(node).hasClass("jstree-closed") || $(node).hasClass("jstree-open")) {
              delete items.deleteItem;
              delete items.renameItem;
          }
  
          else{
              delete items.createItem;
          }
  
          return items;
      }
  
      $('#tree').jstree({
          'core': {
              'data': [
                  { "id": "ajson1", "parent": "#", "text": "Folder 1" },
                  { "id": "ajson2", "parent": "ajson1", "text": "File 1" },
                  { "id": "ajson3", "parent": "ajson1", "text": "File 2" }
              ]
          },
          "plugins": [ "contextmenu" ],
          "contextmenu": {items: customMenu}
      });
  });
  </code></pre>