Create Functionality in Context Menu of jsTree not working2019 Community Moderator ElectionIs there an “exists” function for jQuery?Create GUID / UUID in JavaScript?How do JavaScript closures work?Event binding on dynamically created elements?var functionName = function() vs function functionName() Creating multiline strings in JavaScriptSet a default parameter value for a JavaScript functionWhat is JSONP, and why was it created?jstree dnd access created elementJsTree : preventing drag and drop between two different trees

If nine coins are tossed, what is the probability that the number of heads is even?

PTIJ: Sport in the Torah

How does a sound wave propagate?

After Brexit, will the EU recognize British passports that are valid for more than ten years?

What should I do when a paper is published similar to my PhD thesis without citation?

Propulsion Systems

What is better: yes / no radio, or simple checkbox?

Giving a career talk in my old university, how prominently should I tell students my salary?

“I had a flat in the centre of town, but I didn’t like living there, so …”

Create chunks from an array

Is it a Cyclops number? "Nobody" knows!

What is the oldest European royal house?

Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?

Why isn't P and P/poly trivially the same?

I can't die. Who am I?

Short SF story. Females use stingers to implant eggs in yearfathers

Was this cameo in Captain Marvel computer generated?

Did Amazon pay $0 in taxes last year?

Does the US political system, in principle, allow for a no-party system?

Are small insurances worth it?

School performs periodic password audits. Is my password compromised?

How could it rain oil?

Who has more? Ireland or Iceland?

How do you use environments that have the same name within a single latex document?



Create Functionality in Context Menu of jsTree not working



2019 Community Moderator ElectionIs there an “exists” function for jQuery?Create GUID / UUID in JavaScript?How do JavaScript closures work?Event binding on dynamically created elements?var functionName = function() vs function functionName() Creating multiline strings in JavaScriptSet a default parameter value for a JavaScript functionWhat is JSONP, and why was it created?jstree dnd access created elementJsTree : preventing drag and drop between two different trees










2















New nodes won't be created when 'types' plugin is defined.



Please look at this fiddle.
I'm unable to create new Nodes in the tree.
http://jsfiddle.net/z8L5r9w3/1/



$('#jstree').jstree(
"core" :
"check_callback" : true,
"data" : [
"text" : "Branch 1", "type" : "branch", "children" : [
"text" : "leaf 1.1", "type" : "leaf" ,
"text" : "leaf 1.2", "type" : "leaf" ,
"text" : "leaf 1.3", "type" : "leaf"
]
,
"text" : "Branch 2", "type" : "branch", "children" : [
"text" : "leaf 2.1", "type" : "leaf" ,
"text" : "leaf 2.2", "type" : "leaf" ,
"text" : "leaf 2.3", "type" : "leaf"
]

]
,
"types" :
"#" :
"valid_children" : ["branch"]
,
"branch" :
"valid_children" : ["leaf"]
,
"leaf" :
"valid_children" : []

,
"plugins" : ["types", "dnd", "contextmenu"]);









share|improve this question


























    2















    New nodes won't be created when 'types' plugin is defined.



    Please look at this fiddle.
    I'm unable to create new Nodes in the tree.
    http://jsfiddle.net/z8L5r9w3/1/



    $('#jstree').jstree(
    "core" :
    "check_callback" : true,
    "data" : [
    "text" : "Branch 1", "type" : "branch", "children" : [
    "text" : "leaf 1.1", "type" : "leaf" ,
    "text" : "leaf 1.2", "type" : "leaf" ,
    "text" : "leaf 1.3", "type" : "leaf"
    ]
    ,
    "text" : "Branch 2", "type" : "branch", "children" : [
    "text" : "leaf 2.1", "type" : "leaf" ,
    "text" : "leaf 2.2", "type" : "leaf" ,
    "text" : "leaf 2.3", "type" : "leaf"
    ]

    ]
    ,
    "types" :
    "#" :
    "valid_children" : ["branch"]
    ,
    "branch" :
    "valid_children" : ["leaf"]
    ,
    "leaf" :
    "valid_children" : []

    ,
    "plugins" : ["types", "dnd", "contextmenu"]);









    share|improve this question
























      2












      2








      2


      1






      New nodes won't be created when 'types' plugin is defined.



      Please look at this fiddle.
      I'm unable to create new Nodes in the tree.
      http://jsfiddle.net/z8L5r9w3/1/



      $('#jstree').jstree(
      "core" :
      "check_callback" : true,
      "data" : [
      "text" : "Branch 1", "type" : "branch", "children" : [
      "text" : "leaf 1.1", "type" : "leaf" ,
      "text" : "leaf 1.2", "type" : "leaf" ,
      "text" : "leaf 1.3", "type" : "leaf"
      ]
      ,
      "text" : "Branch 2", "type" : "branch", "children" : [
      "text" : "leaf 2.1", "type" : "leaf" ,
      "text" : "leaf 2.2", "type" : "leaf" ,
      "text" : "leaf 2.3", "type" : "leaf"
      ]

      ]
      ,
      "types" :
      "#" :
      "valid_children" : ["branch"]
      ,
      "branch" :
      "valid_children" : ["leaf"]
      ,
      "leaf" :
      "valid_children" : []

      ,
      "plugins" : ["types", "dnd", "contextmenu"]);









      share|improve this question














      New nodes won't be created when 'types' plugin is defined.



      Please look at this fiddle.
      I'm unable to create new Nodes in the tree.
      http://jsfiddle.net/z8L5r9w3/1/



      $('#jstree').jstree(
      "core" :
      "check_callback" : true,
      "data" : [
      "text" : "Branch 1", "type" : "branch", "children" : [
      "text" : "leaf 1.1", "type" : "leaf" ,
      "text" : "leaf 1.2", "type" : "leaf" ,
      "text" : "leaf 1.3", "type" : "leaf"
      ]
      ,
      "text" : "Branch 2", "type" : "branch", "children" : [
      "text" : "leaf 2.1", "type" : "leaf" ,
      "text" : "leaf 2.2", "type" : "leaf" ,
      "text" : "leaf 2.3", "type" : "leaf"
      ]

      ]
      ,
      "types" :
      "#" :
      "valid_children" : ["branch"]
      ,
      "branch" :
      "valid_children" : ["leaf"]
      ,
      "leaf" :
      "valid_children" : []

      ,
      "plugins" : ["types", "dnd", "contextmenu"]);






      javascript jquery jstree jstree-dnd jstree-search






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      G.BrownG.Brown

      185




      185






















          2 Answers
          2






          active

          oldest

          votes


















          2














          Also, you can override "contextmenu"



           "contextmenu":
          "items": function ()
          return
          "Create":
          "label": "Create",
          "action": function (data)
          var ref = $.jstree.reference(data.reference);
          sel = ref.get_selected();
          if(!sel.length) return false;
          sel = sel[0];
          type = ref.get_type(sel);
          if (type == "#")
          type = "branch";
          else if (type == "branch")
          type = "leaf";
          else if (type == "leaf")
          type = "";
          sel = ref.create_node(sel, text: "new "+type, type: type);
          if(sel)
          ref.edit(sel);



          ,
          "Rename":
          "label": "Rename",
          "action": function (data)
          var inst = $.jstree.reference(data.reference);
          obj = inst.get_node(data.reference);
          inst.edit(obj);

          ,
          "Delete":
          "label": "Delete",
          "action": function (data)
          var ref = $.jstree.reference(data.reference),
          sel = ref.get_selected();
          if(!sel.length) return false;
          ref.delete_node(sel);



          ;

          ,





          share|improve this answer








          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • can we add copy-paste and cut-paste to this customised context view as well

            – G.Brown
            yesterday






          • 1





            Of course you can. You can add whatever you want.

            – Yaroslav Nudnenko
            yesterday


















          2














          You have a problem with "types". The "Create" action in the "contextmenu" does not know about the types of "branch" and "leaf" and create new node with "type" : "default".
          You can see this:



           "types" : 
          "#" :
          "valid_children" : ["branch", "default"]
          ,
          "branch" :
          "valid_children" : ["leaf", "default"]
          ,
          "leaf" :
          "valid_children" : []

          ,





          share|improve this answer










          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • so, what would be the solution? Can you provide a sample fiddle

            – G.Brown
            2 days ago












          • Another sample script stackoverflow.com/a/55040567/11148620

            – Yaroslav Nudnenko
            yesterday










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023377%2fcreate-functionality-in-context-menu-of-jstree-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Also, you can override "contextmenu"



           "contextmenu":
          "items": function ()
          return
          "Create":
          "label": "Create",
          "action": function (data)
          var ref = $.jstree.reference(data.reference);
          sel = ref.get_selected();
          if(!sel.length) return false;
          sel = sel[0];
          type = ref.get_type(sel);
          if (type == "#")
          type = "branch";
          else if (type == "branch")
          type = "leaf";
          else if (type == "leaf")
          type = "";
          sel = ref.create_node(sel, text: "new "+type, type: type);
          if(sel)
          ref.edit(sel);



          ,
          "Rename":
          "label": "Rename",
          "action": function (data)
          var inst = $.jstree.reference(data.reference);
          obj = inst.get_node(data.reference);
          inst.edit(obj);

          ,
          "Delete":
          "label": "Delete",
          "action": function (data)
          var ref = $.jstree.reference(data.reference),
          sel = ref.get_selected();
          if(!sel.length) return false;
          ref.delete_node(sel);



          ;

          ,





          share|improve this answer








          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • can we add copy-paste and cut-paste to this customised context view as well

            – G.Brown
            yesterday






          • 1





            Of course you can. You can add whatever you want.

            – Yaroslav Nudnenko
            yesterday















          2














          Also, you can override "contextmenu"



           "contextmenu":
          "items": function ()
          return
          "Create":
          "label": "Create",
          "action": function (data)
          var ref = $.jstree.reference(data.reference);
          sel = ref.get_selected();
          if(!sel.length) return false;
          sel = sel[0];
          type = ref.get_type(sel);
          if (type == "#")
          type = "branch";
          else if (type == "branch")
          type = "leaf";
          else if (type == "leaf")
          type = "";
          sel = ref.create_node(sel, text: "new "+type, type: type);
          if(sel)
          ref.edit(sel);



          ,
          "Rename":
          "label": "Rename",
          "action": function (data)
          var inst = $.jstree.reference(data.reference);
          obj = inst.get_node(data.reference);
          inst.edit(obj);

          ,
          "Delete":
          "label": "Delete",
          "action": function (data)
          var ref = $.jstree.reference(data.reference),
          sel = ref.get_selected();
          if(!sel.length) return false;
          ref.delete_node(sel);



          ;

          ,





          share|improve this answer








          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • can we add copy-paste and cut-paste to this customised context view as well

            – G.Brown
            yesterday






          • 1





            Of course you can. You can add whatever you want.

            – Yaroslav Nudnenko
            yesterday













          2












          2








          2







          Also, you can override "contextmenu"



           "contextmenu":
          "items": function ()
          return
          "Create":
          "label": "Create",
          "action": function (data)
          var ref = $.jstree.reference(data.reference);
          sel = ref.get_selected();
          if(!sel.length) return false;
          sel = sel[0];
          type = ref.get_type(sel);
          if (type == "#")
          type = "branch";
          else if (type == "branch")
          type = "leaf";
          else if (type == "leaf")
          type = "";
          sel = ref.create_node(sel, text: "new "+type, type: type);
          if(sel)
          ref.edit(sel);



          ,
          "Rename":
          "label": "Rename",
          "action": function (data)
          var inst = $.jstree.reference(data.reference);
          obj = inst.get_node(data.reference);
          inst.edit(obj);

          ,
          "Delete":
          "label": "Delete",
          "action": function (data)
          var ref = $.jstree.reference(data.reference),
          sel = ref.get_selected();
          if(!sel.length) return false;
          ref.delete_node(sel);



          ;

          ,





          share|improve this answer








          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          Also, you can override "contextmenu"



           "contextmenu":
          "items": function ()
          return
          "Create":
          "label": "Create",
          "action": function (data)
          var ref = $.jstree.reference(data.reference);
          sel = ref.get_selected();
          if(!sel.length) return false;
          sel = sel[0];
          type = ref.get_type(sel);
          if (type == "#")
          type = "branch";
          else if (type == "branch")
          type = "leaf";
          else if (type == "leaf")
          type = "";
          sel = ref.create_node(sel, text: "new "+type, type: type);
          if(sel)
          ref.edit(sel);



          ,
          "Rename":
          "label": "Rename",
          "action": function (data)
          var inst = $.jstree.reference(data.reference);
          obj = inst.get_node(data.reference);
          inst.edit(obj);

          ,
          "Delete":
          "label": "Delete",
          "action": function (data)
          var ref = $.jstree.reference(data.reference),
          sel = ref.get_selected();
          if(!sel.length) return false;
          ref.delete_node(sel);



          ;

          ,






          share|improve this answer








          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered yesterday









          Yaroslav NudnenkoYaroslav Nudnenko

          764




          764




          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.












          • can we add copy-paste and cut-paste to this customised context view as well

            – G.Brown
            yesterday






          • 1





            Of course you can. You can add whatever you want.

            – Yaroslav Nudnenko
            yesterday

















          • can we add copy-paste and cut-paste to this customised context view as well

            – G.Brown
            yesterday






          • 1





            Of course you can. You can add whatever you want.

            – Yaroslav Nudnenko
            yesterday
















          can we add copy-paste and cut-paste to this customised context view as well

          – G.Brown
          yesterday





          can we add copy-paste and cut-paste to this customised context view as well

          – G.Brown
          yesterday




          1




          1





          Of course you can. You can add whatever you want.

          – Yaroslav Nudnenko
          yesterday





          Of course you can. You can add whatever you want.

          – Yaroslav Nudnenko
          yesterday













          2














          You have a problem with "types". The "Create" action in the "contextmenu" does not know about the types of "branch" and "leaf" and create new node with "type" : "default".
          You can see this:



           "types" : 
          "#" :
          "valid_children" : ["branch", "default"]
          ,
          "branch" :
          "valid_children" : ["leaf", "default"]
          ,
          "leaf" :
          "valid_children" : []

          ,





          share|improve this answer










          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • so, what would be the solution? Can you provide a sample fiddle

            – G.Brown
            2 days ago












          • Another sample script stackoverflow.com/a/55040567/11148620

            – Yaroslav Nudnenko
            yesterday















          2














          You have a problem with "types". The "Create" action in the "contextmenu" does not know about the types of "branch" and "leaf" and create new node with "type" : "default".
          You can see this:



           "types" : 
          "#" :
          "valid_children" : ["branch", "default"]
          ,
          "branch" :
          "valid_children" : ["leaf", "default"]
          ,
          "leaf" :
          "valid_children" : []

          ,





          share|improve this answer










          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • so, what would be the solution? Can you provide a sample fiddle

            – G.Brown
            2 days ago












          • Another sample script stackoverflow.com/a/55040567/11148620

            – Yaroslav Nudnenko
            yesterday













          2












          2








          2







          You have a problem with "types". The "Create" action in the "contextmenu" does not know about the types of "branch" and "leaf" and create new node with "type" : "default".
          You can see this:



           "types" : 
          "#" :
          "valid_children" : ["branch", "default"]
          ,
          "branch" :
          "valid_children" : ["leaf", "default"]
          ,
          "leaf" :
          "valid_children" : []

          ,





          share|improve this answer










          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          You have a problem with "types". The "Create" action in the "contextmenu" does not know about the types of "branch" and "leaf" and create new node with "type" : "default".
          You can see this:



           "types" : 
          "#" :
          "valid_children" : ["branch", "default"]
          ,
          "branch" :
          "valid_children" : ["leaf", "default"]
          ,
          "leaf" :
          "valid_children" : []

          ,






          share|improve this answer










          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer








          edited 2 days ago





















          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered 2 days ago









          Yaroslav NudnenkoYaroslav Nudnenko

          764




          764




          New contributor




          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Yaroslav Nudnenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.












          • so, what would be the solution? Can you provide a sample fiddle

            – G.Brown
            2 days ago












          • Another sample script stackoverflow.com/a/55040567/11148620

            – Yaroslav Nudnenko
            yesterday

















          • so, what would be the solution? Can you provide a sample fiddle

            – G.Brown
            2 days ago












          • Another sample script stackoverflow.com/a/55040567/11148620

            – Yaroslav Nudnenko
            yesterday
















          so, what would be the solution? Can you provide a sample fiddle

          – G.Brown
          2 days ago






          so, what would be the solution? Can you provide a sample fiddle

          – G.Brown
          2 days ago














          Another sample script stackoverflow.com/a/55040567/11148620

          – Yaroslav Nudnenko
          yesterday





          Another sample script stackoverflow.com/a/55040567/11148620

          – Yaroslav Nudnenko
          yesterday

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023377%2fcreate-functionality-in-context-menu-of-jstree-not-working%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко