Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:36:38+00:00 2026-05-27T23:36:38+00:00

I am working on contextmenu for jstree, and apparently needed a clone functionality in

  • 0

I am working on contextmenu for jstree, and apparently needed a clone functionality in right click menu which will actually be simulation of copy , paste and rename, so that once user right clicks on an item and then clicks on clone, a node is copied (copied and pasted in the tree , and focused with rename highlight so that user could rename it right there.

I tried code below for custom clone menu item, but it doesn’t work

cloneItem: { // The “clone” menu item
label: “Clone”,
action: function (obj)
{
this.copy(obj);
this.paste(obj);
}
}

Any help is very much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:36:39+00:00Added an answer on May 27, 2026 at 11:36 pm

    After research I figured out how this clone could be implemented, the key to do this was as paste goes on parent node of copied node. here is code.

    cloneItem: { 
            label: "Clone",             
            action: function (obj) 
            {
                var currentId = this._get_node(obj).attr("id");
                var parentId = this._get_node(obj)[0].firstChild.parentElement.parentNode.parentElement.id;
                $("#TreeDiv").jstree("copy"); 
                $("#TreeDiv").jstree("select_node","#"+parentId);
                $("#TreeDiv").jstree("paste"); 
                $("#TreeDiv").jstree("deselect_node","#"+parentId)
                $("#TreeDiv").jstree("deselect_node", "#"+currentId)
                $("#TreeDiv").jstree("select_node","#copy_"+currentId);
                $("#TreeDiv").jstree("rename");   
            } 
    
        },
    

    steps to do this are

    • copy the current item using .jstree(“copy”);
    • select the parent node of copied item using .jstree(“select_node”,”#”+parentId);
    • paste the copied item ( its copied over selected item , means parent ) using .jstree(“paste”);
    • now deselect both parent and copied element using .jstree(“deselect_node”,”#”+parentId) and .jstree(“deselect_node”, “#”+currentId)
    • Before renaming select the copied node, the copied items gets id as copy_, so do this by .jstree(“select_node”,”#copy_”+currentId);
    • and the final step to do is by .jstree(“rename”);

    I hope it will help someone, who needs clone in jstree.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm am working on a little chrome extension which uses the contextMenu to add
I'm working on a function that will return a context menu for use within
I needed a dynamic context menu for my jstree so created my own but
Working with python interactively, it's sometimes necessary to display a result which is some
I want to disable the default contextMenu when a user right-clicks on an input
I want to trigger the click, to which following code is listening: chrome.browserAction.onClicked.addListener(function(tab) {});
I am working on a node-graph-view similar to Maya's HyperGraph in which I can
I am working on a WPF application which has a treeview that represents an
In my application I have the following jsTree created $('#categoryTree').jstree({ plugins: ['themes', 'html_data', 'contextmenu',
I have styled my Menu/ContextMenu/MenuItem controls in App.xaml so that those styles apply to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.