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

  • Home
  • SEARCH
  • 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 9279959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:45:22+00:00 2026-06-18T17:45:22+00:00

I am using jstree library to display a tree. In the code below, I

  • 0

I am using jstree library to display a tree.

In the code below, I am looping through the selected nodes in the tree and based on some conditions, I am assigning a variable ‘allow_edit’ a boolean value.

I would like to break the main loop if 'allow_edit = false'.

I tried using label and breaking the loop but this does not seem to work. I am getting undefined label.

loop1:
$j.each($j("#demo2").jstree("get_selected"), function(index, element) {

  var selected_node_depth = parseInt($j(element).attr('node_depth'));
  var allow_edit = false;


  var array_first_filter = $j.grep(array_first, function(v) { return v[1]  != "not detected";})
  var array_second_filter = $j.grep(array_first_filter, function(v) { return v[3] > selected_node_depth;})


  if (array_second_filter.length === 0 || array_second_filter.length == null)
  {
    allow_edit = true;
  }
  else{
    alert("Confliction exists in your selected terms.");
    allow_edit = false;
    //break loop1; /** not working, getting undefined label **/
  }


}

Any suggestions on how to break the main loop if 'allow_edit = false'? Thanks a lot

  • 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-06-18T17:45:23+00:00Added an answer on June 18, 2026 at 5:45 pm

    If the function you pass to .each() returns false, the iteration will stop.

    else {
      allow_edit = false; // pointless since you're about to return ...
      return false;
    }
    

    Also, as a programming style note, any construction of the form:

    if (something) {
      flag = true;
    }
    else {
      flag = false;
    }
    

    can be better written as simply:

    flag = something;
    

    In JavaScript, to force flag to be boolean (true or false), you can do this:

    flag = !!(something);
    

    The two ! (logical “not”) operators force the expression (“something”) to be evaluated as a boolean by the same rules as are used when that expression is the test clause of an if statement.

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

Sidebar

Related Questions

I'm using jsTree and I need to convert this HTML tag tree code <ul>
I am using jstree and several nodes in my tree have the same name.
I am using jsTree to display a tree structure of hierarchical data within my
I'm using jstree to create a multi-level tree, and I want to be able
I'm using the jstree plugin, with an ajax call. At some point, I call
Im using ajax loading for children nodes in JQuery JsTree plugin. I need to
I am creating a node by using crrm as below $(#TreeDiv).jstree(create, $(#somenode), inside, {
I am using the following code: $("#treeview").jstree(); $("#treeview").jstree('open_all'); With the following html: <div id="treeview">
We are using jsTree for tree representation of the Files and folders. Files and
I am using jstree to build a tree menu. When you select an item

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.