or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

checkbox.mdconfiguration.mdcontextmenu.mdcore.mddnd.mdevents.mdindex.mdplugins.mdsearch.md
tile.json

core.mddocs/

0

# Core Tree Management

1

2

Essential tree functionality including initialization, node manipulation, selection, and basic operations. The core provides all fundamental tree operations and serves as the foundation for plugin extensions.

3

4

## Capabilities

5

6

### Plugin Interface

7

8

Main entry point for creating and interacting with jsTree instances.

9

10

```javascript { .api }

11

/**

12

* Initialize jsTree on selected elements or call methods on existing instances

13

* @param options - Configuration object for new instances

14

* @returns jQuery object for chaining

15

*/

16

$(selector).jstree(options?: object): jQuery;

17

18

/**

19

* Call methods on existing jsTree instances

20

* @param method - Method name to call

21

* @param args - Arguments to pass to the method

22

* @returns Method return value

23

*/

24

$(selector).jstree(method: string, ...args: any[]): any;

25

26

/**

27

* Get reference to jsTree instance without calling methods

28

* @param getinstance - Must be true to get instance

29

* @returns jsTree instance or false if not found

30

*/

31

$(selector).jstree(getinstance: true): jsTree|false;

32

```

33

34

**Usage Examples:**

35

36

```javascript

37

// Initialize with options

38

$("#tree").jstree({

39

"core": {

40

"data": ["Root", "Child 1", "Child 2"]

41

},

42

"plugins": ["checkbox", "search"]

43

});

44

45

// Call method on existing instance

46

$("#tree").jstree("select_node", "node_id");

47

48

// Get instance reference

49

const tree = $("#tree").jstree(true);

50

if (tree) {

51

tree.select_node("node_id");

52

}

53

```

54

55

### Static Methods

56

57

Global jsTree methods for instance management and utilities.

58

59

```javascript { .api }

60

/**

61

* Create a jsTree instance programmatically

62

* @param el - Element, jQuery object, or selector

63

* @param options - Configuration options

64

* @returns New jsTree instance

65

*/

66

$.jstree.create(el: Element|jQuery|string, options?: object): jsTree;

67

68

/**

69

* Destroy all jsTree instances globally

70

*/

71

$.jstree.destroy(): void;

72

73

/**

74

* Get reference to existing jsTree instance

75

* @param needle - Element, jQuery object, selector, or instance ID

76

* @returns jsTree instance or null if not found

77

*/

78

$.jstree.reference(needle: Element|jQuery|string): jsTree|null;

79

```

80

81

### Node Retrieval and Navigation

82

83

Methods for finding and navigating between nodes in the tree.

84

85

```javascript { .api }

86

/**

87

* Get node object by ID, element, or selector

88

* @param obj - Node identifier

89

* @param as_dom - Return DOM element instead of node object

90

* @returns Node object or DOM element

91

*/

92

get_node(obj: string|object|Element, as_dom?: boolean): object|Element|false;

93

94

/**

95

* Get the tree container element

96

* @returns Tree container jQuery object

97

*/

98

get_container(): jQuery;

99

100

/**

101

* Get the main UL element of the tree

102

* @returns Main UL jQuery object

103

*/

104

get_container_ul(): jQuery;

105

106

/**

107

* Get path from root to specified node

108

* @param obj - Target node

109

* @param glue - String to join path segments (default: "/")

110

* @param ids - Use node IDs instead of text (default: false)

111

* @returns Path string or array

112

*/

113

get_path(obj: string|object, glue?: string, ids?: boolean): string|Array<string>;

114

115

/**

116

* Get next visible node in DOM order

117

* @param obj - Current node

118

* @param strict - Only return nodes at same level

119

* @returns Next node object or false

120

*/

121

get_next_dom(obj: string|object, strict?: boolean): object|false;

122

123

/**

124

* Get previous visible node in DOM order

125

* @param obj - Current node

126

* @param strict - Only return nodes at same level

127

* @returns Previous node object or false

128

*/

129

get_prev_dom(obj: string|object, strict?: boolean): object|false;

130

131

/**

132

* Get parent node

133

* @param obj - Child node

134

* @returns Parent node object or false if root

135

*/

136

get_parent(obj: string|object): object|false;

137

138

/**

139

* Get children DOM elements

140

* @param obj - Parent node

141

* @returns jQuery object containing child elements

142

*/

143

get_children_dom(obj: string|object): jQuery;

144

```

145

146

### Node State Checking

147

148

Methods for checking various states and properties of nodes.

149

150

```javascript { .api }

151

/**

152

* Check if node has children

153

* @param obj - Node to check

154

* @returns True if node has children

155

*/

156

is_parent(obj: string|object): boolean;

157

158

/**

159

* Check if node's children are loaded

160

* @param obj - Node to check

161

* @returns True if children are loaded

162

*/

163

is_loaded(obj: string|object): boolean;

164

165

/**

166

* Check if node is currently loading

167

* @param obj - Node to check

168

* @returns True if loading

169

*/

170

is_loading(obj: string|object): boolean;

171

172

/**

173

* Check if node is open/expanded

174

* @param obj - Node to check

175

* @returns True if open

176

*/

177

is_open(obj: string|object): boolean;

178

179

/**

180

* Check if node is closed/collapsed

181

* @param obj - Node to check

182

* @returns True if closed

183

*/

184

is_closed(obj: string|object): boolean;

185

186

/**

187

* Check if node is a leaf (has no children)

188

* @param obj - Node to check

189

* @returns True if leaf node

190

*/

191

is_leaf(obj: string|object): boolean;

192

193

/**

194

* Check if node is disabled

195

* @param obj - Node to check

196

* @returns True if disabled

197

*/

198

is_disabled(obj: string|object): boolean;

199

200

/**

201

* Check if node is hidden

202

* @param obj - Node to check

203

* @returns True if hidden

204

*/

205

is_hidden(obj: string|object): boolean;

206

207

/**

208

* Check if node is selected

209

* @param obj - Node to check

210

* @returns True if selected

211

*/

212

is_selected(obj: string|object): boolean;

213

```

214

215

### Node Loading and Data

216

217

Methods for loading node data and managing tree state.

218

219

```javascript { .api }

220

/**

221

* Load node children via AJAX or callback

222

* @param obj - Node to load children for

223

* @param callback - Function to call when loading completes

224

* @returns True if loading started

225

*/

226

load_node(obj: string|object, callback?: function): boolean;

227

228

/**

229

* Load all descendants of a node

230

* @param obj - Node to load descendants for (default: root)

231

* @param callback - Function to call when loading completes

232

* @returns True if loading started

233

*/

234

load_all(obj?: string|object, callback?: function): boolean;

235

236

/**

237

* Refresh the entire tree or specific node

238

* @param skip_loading - Don't trigger loading events

239

* @param forget_state - Don't restore previous state

240

* @returns True if refresh started

241

*/

242

refresh(skip_loading?: boolean, forget_state?: boolean): boolean;

243

244

/**

245

* Refresh a specific node

246

* @param obj - Node to refresh

247

* @returns True if refresh started

248

*/

249

refresh_node(obj: string|object): boolean;

250

251

/**

252

* Export tree data as JSON

253

* @param obj - Node to export (default: all)

254

* @param options - Export options

255

* @param flat - Return flat array instead of nested

256

* @returns JSON representation of tree data

257

*/

258

get_json(obj?: string|object, options?: object, flat?: boolean): Array<object>|object;

259

260

/**

261

* Get current tree state (selected, opened nodes, etc.)

262

* @returns State object

263

*/

264

get_state(): object;

265

266

/**

267

* Restore tree state

268

* @param state - State object to restore

269

* @param callback - Function to call when restoration completes

270

*/

271

set_state(state: object, callback?: function): void;

272

```

273

274

### Node Manipulation

275

276

Methods for creating, modifying, and removing nodes.

277

278

```javascript { .api }

279

/**

280

* Create a new node

281

* @param parent - Parent node ID or object (# for root)

282

* @param node - Node data object or string

283

* @param position - Position to insert ("first", "last", number, or "before"/"after" existing node)

284

* @param callback - Function to call when creation completes

285

* @param is_loaded - Skip loading parent node children

286

* @returns New node ID or false on failure

287

*/

288

create_node(parent: string|object, node: object|string, position?: string|number, callback?: function, is_loaded?: boolean): string|false;

289

290

/**

291

* Rename a node

292

* @param obj - Node to rename

293

* @param text - New text for the node

294

* @returns True on success

295

*/

296

rename_node(obj: string|object, text: string): boolean;

297

298

/**

299

* Delete a node and all its children

300

* @param obj - Node to delete

301

* @returns True on success

302

*/

303

delete_node(obj: string|object): boolean;

304

305

/**

306

* Move a node to a new parent/position

307

* @param obj - Node to move

308

* @param parent - New parent node

309

* @param position - Position in new parent

310

* @param callback - Function to call when move completes

311

* @param is_loaded - Skip loading parent children

312

* @param skip_redraw - Don't redraw after move

313

* @param origin - Internal parameter for tracking move origin

314

* @returns True on success

315

*/

316

move_node(obj: string|object, parent: string|object, position?: string|number, callback?: function, is_loaded?: boolean, skip_redraw?: boolean, origin?: object): boolean;

317

318

/**

319

* Copy a node to a new parent/position

320

* @param obj - Node to copy

321

* @param parent - New parent node

322

* @param position - Position in new parent

323

* @param callback - Function to call when copy completes

324

* @param is_loaded - Skip loading parent children

325

* @param skip_redraw - Don't redraw after copy

326

* @param origin - Internal parameter for tracking copy origin

327

* @returns New node ID or false on failure

328

*/

329

copy_node(obj: string|object, parent: string|object, position?: string|number, callback?: function, is_loaded?: boolean, skip_redraw?: boolean, origin?: object): string|false;

330

```

331

332

### Node Display Control

333

334

Methods for controlling node visibility and expansion state.

335

336

```javascript { .api }

337

/**

338

* Open/expand a node

339

* @param obj - Node to open

340

* @param callback - Function to call when opening completes

341

* @param animation - Animation duration (overrides global setting)

342

* @returns True on success

343

*/

344

open_node(obj: string|object, callback?: function, animation?: number|boolean): boolean;

345

346

/**

347

* Close/collapse a node

348

* @param obj - Node to close

349

* @param animation - Animation duration (overrides global setting)

350

* @returns True on success

351

*/

352

close_node(obj: string|object, animation?: number|boolean): boolean;

353

354

/**

355

* Toggle node open/closed state

356

* @param obj - Node to toggle

357

* @returns True on success

358

*/

359

toggle_node(obj: string|object): boolean;

360

361

/**

362

* Open all nodes in the tree

363

* @param obj - Starting node (default: root)

364

* @param animation - Animation duration

365

* @param original_obj - Internal parameter

366

* @returns True on success

367

*/

368

open_all(obj?: string|object, animation?: number|boolean, original_obj?: object): boolean;

369

370

/**

371

* Close all nodes in the tree

372

* @param obj - Starting node (default: root)

373

* @param animation - Animation duration

374

* @returns True on success

375

*/

376

close_all(obj?: string|object, animation?: number|boolean): boolean;

377

378

/**

379

* Enable a disabled node

380

* @param obj - Node to enable

381

* @returns True on success

382

*/

383

enable_node(obj: string|object): boolean;

384

385

/**

386

* Disable a node (prevents interaction)

387

* @param obj - Node to disable

388

* @returns True on success

389

*/

390

disable_node(obj: string|object): boolean;

391

392

/**

393

* Hide a node

394

* @param obj - Node to hide

395

* @param skip_redraw - Don't redraw after hiding

396

* @returns True on success

397

*/

398

hide_node(obj: string|object, skip_redraw?: boolean): boolean;

399

400

/**

401

* Show a hidden node

402

* @param obj - Node to show

403

* @param skip_redraw - Don't redraw after showing

404

* @returns True on success

405

*/

406

show_node(obj: string|object, skip_redraw?: boolean): boolean;

407

408

/**

409

* Hide all nodes in the tree

410

* @param skip_redraw - Don't redraw after hiding

411

* @returns True on success

412

*/

413

hide_all(skip_redraw?: boolean): boolean;

414

415

/**

416

* Show all hidden nodes in the tree

417

* @param skip_redraw - Don't redraw after showing

418

* @returns True on success

419

*/

420

show_all(skip_redraw?: boolean): boolean;

421

```

422

423

### Node Selection

424

425

Methods for managing node selection state.

426

427

```javascript { .api }

428

/**

429

* Select a node

430

* @param obj - Node to select

431

* @param supress_event - Don't trigger select event

432

* @param prevent_open - Don't open parent nodes

433

* @param e - Original event object

434

* @returns True on success

435

*/

436

select_node(obj: string|object, supress_event?: boolean, prevent_open?: boolean, e?: Event): boolean;

437

438

/**

439

* Deselect a node

440

* @param obj - Node to deselect

441

* @param supress_event - Don't trigger deselect event

442

* @param e - Original event object

443

* @returns True on success

444

*/

445

deselect_node(obj: string|object, supress_event?: boolean, e?: Event): boolean;

446

447

/**

448

* Select all nodes

449

* @param supress_event - Don't trigger select events

450

* @returns True on success

451

*/

452

select_all(supress_event?: boolean): boolean;

453

454

/**

455

* Deselect all nodes

456

* @param supress_event - Don't trigger deselect events

457

* @returns True on success

458

*/

459

deselect_all(supress_event?: boolean): boolean;

460

461

/**

462

* Get selected nodes

463

* @param full - Return full node objects instead of IDs

464

* @returns Array of selected node IDs or objects

465

*/

466

get_selected(full?: boolean): Array<string|object>;

467

468

/**

469

* Get top-level selected nodes (selected nodes with no selected ancestors)

470

* @param full - Return full node objects instead of IDs

471

* @returns Array of top-level selected node IDs or objects

472

*/

473

get_top_selected(full?: boolean): Array<string|object>;

474

475

/**

476

* Get bottom-level selected nodes (selected nodes with no selected descendants)

477

* @param full - Return full node objects instead of IDs

478

* @returns Array of bottom-level selected node IDs or objects

479

*/

480

get_bottom_selected(full?: boolean): Array<string|object>;

481

```

482

483

### Node Interaction

484

485

Methods for programmatic node interaction and focus management.

486

487

```javascript { .api }

488

/**

489

* Activate a node (focus and trigger activation events)

490

* @param obj - Node to activate

491

* @param e - Original event object

492

* @returns True on success

493

*/

494

activate_node(obj: string|object, e?: Event): boolean;

495

496

/**

497

* Apply hover state to a node

498

* @param obj - Node to hover

499

* @returns True on success

500

*/

501

hover_node(obj: string|object): boolean;

502

503

/**

504

* Remove hover state from a node

505

* @param obj - Node to remove hover from

506

* @returns True on success

507

*/

508

dehover_node(obj: string|object): boolean;

509

```

510

511

### Text and Content

512

513

Methods for getting and setting node text and IDs.

514

515

```javascript { .api }

516

/**

517

* Get the text content of a node

518

* @param obj - Node to get text from

519

* @returns Node text content

520

*/

521

get_text(obj: string|object): string;

522

523

/**

524

* Set the text content of a node

525

* @param obj - Node to set text for

526

* @param text - New text content

527

* @returns True on success

528

*/

529

set_text(obj: string|object, text: string): boolean;

530

531

/**

532

* Set the ID of a node

533

* @param obj - Node to set ID for

534

* @param id - New ID (must be unique)

535

* @returns True on success

536

*/

537

set_id(obj: string|object, id: string): boolean;

538

```

539

540

### Clipboard Operations

541

542

Methods for cut, copy, and paste operations on nodes.

543

544

```javascript { .api }

545

/**

546

* Cut nodes to clipboard

547

* @param obj - Nodes to cut

548

* @returns True on success

549

*/

550

cut(obj: string|object|Array): boolean;

551

552

/**

553

* Copy nodes to clipboard

554

* @param obj - Nodes to copy

555

* @returns True on success

556

*/

557

copy(obj: string|object|Array): boolean;

558

559

/**

560

* Paste nodes from clipboard

561

* @param obj - Target parent node

562

* @param pos - Position to paste ("first", "last", etc.)

563

* @returns True on success

564

*/

565

paste(obj: string|object, pos?: string|number): boolean;

566

567

/**

568

* Get clipboard contents

569

* @returns Clipboard object with nodes and mode

570

*/

571

get_buffer(): object;

572

573

/**

574

* Check if paste operation is possible

575

* @returns True if paste is valid

576

*/

577

can_paste(): boolean;

578

579

/**

580

* Clear the clipboard

581

*/

582

clear_buffer(): void;

583

```

584

585

### Inline Editing

586

587

Methods for enabling inline text editing of nodes.

588

589

```javascript { .api }

590

/**

591

* Start inline editing of a node

592

* @param obj - Node to edit

593

* @param default_text - Default text to show in editor

594

* @param callback - Function to call when editing completes

595

* @returns True if editing started

596

*/

597

edit(obj: string|object, default_text?: string, callback?: function): boolean;

598

```

599

600

### Theme and Appearance

601

602

Methods for controlling visual appearance and themes.

603

604

```javascript { .api }

605

/**

606

* Set the theme for the tree

607

* @param theme_name - Theme name to use

608

* @param theme_url - URL to theme CSS file

609

* @returns True on success

610

*/

611

set_theme(theme_name: string, theme_url?: string): boolean;

612

613

/**

614

* Get the current theme name

615

* @returns Current theme name

616

*/

617

get_theme(): string;

618

619

/**

620

* Set theme variant

621

* @param variant - Variant name (e.g., "large", "small")

622

* @returns True on success

623

*/

624

set_theme_variant(variant: string): boolean;

625

626

/**

627

* Get current theme variant

628

* @returns Current variant name

629

*/

630

get_theme_variant(): string;

631

632

/**

633

* Show connecting dots/lines

634

* @returns True on success

635

*/

636

show_dots(): boolean;

637

638

/**

639

* Hide connecting dots/lines

640

* @returns True on success

641

*/

642

hide_dots(): boolean;

643

644

/**

645

* Toggle connecting dots/lines visibility

646

* @returns True on success

647

*/

648

toggle_dots(): boolean;

649

650

/**

651

* Show node icons

652

* @returns True on success

653

*/

654

show_icons(): boolean;

655

656

/**

657

* Hide node icons

658

* @returns True on success

659

*/

660

hide_icons(): boolean;

661

662

/**

663

* Toggle node icon visibility

664

* @returns True on success

665

*/

666

toggle_icons(): boolean;

667

668

/**

669

* Show alternating row stripes

670

* @returns True on success

671

*/

672

show_stripes(): boolean;

673

674

/**

675

* Hide alternating row stripes

676

* @returns True on success

677

*/

678

hide_stripes(): boolean;

679

680

/**

681

* Toggle stripe visibility

682

* @returns True on success

683

*/

684

toggle_stripes(): boolean;

685

686

/**

687

* Show text ellipsis for long node names

688

* @returns True on success

689

*/

690

show_ellipsis(): boolean;

691

692

/**

693

* Hide text ellipsis

694

* @returns True on success

695

*/

696

hide_ellipsis(): boolean;

697

698

/**

699

* Toggle ellipsis visibility

700

* @returns True on success

701

*/

702

toggle_ellipsis(): boolean;

703

```

704

705

### Icons

706

707

Methods for managing node icons.

708

709

```javascript { .api }

710

/**

711

* Get the icon class or URL for a node

712

* @param obj - Node to get icon for

713

* @returns Icon class name or URL

714

*/

715

get_icon(obj: string|object): string|false;

716

717

/**

718

* Set the icon for a node

719

* @param obj - Node to set icon for

720

* @param icon - Icon class name, URL, or false to remove

721

* @returns True on success

722

*/

723

set_icon(obj: string|object, icon: string|false): boolean;

724

```

725

726

### Rendering

727

728

Methods for controlling tree rendering and redrawing.

729

730

```javascript { .api }

731

/**

732

* Redraw the entire tree

733

* @param full - Perform full redraw (slower but more thorough)

734

* @returns True on success

735

*/

736

redraw(full?: boolean): boolean;

737

738

/**

739

* Redraw a specific node

740

* @param node - Node to redraw

741

* @param deep - Also redraw all descendants

742

* @param callback - Function to call when redraw completes

743

* @param force_render - Force rendering even if not visible

744

* @returns True on success

745

*/

746

redraw_node(node: string|object, deep?: boolean, callback?: function, force_render?: boolean): boolean;

747

748

/**

749

* Draw children of a node

750

* @param node - Parent node

751

* @returns True on success

752

*/

753

draw_children(node: string|object): boolean;

754

```

755

756

### Validation and Utilities

757

758

Methods for validation and utility functions.

759

760

```javascript { .api }

761

/**

762

* Check if an operation is allowed by the check_callback

763

* @param operation - Operation name ("create_node", "rename_node", etc.)

764

* @param node - Node being operated on

765

* @param parent - Parent node for the operation

766

* @param position - Position for the operation

767

* @param more - Additional operation-specific data

768

* @returns True if operation is allowed

769

*/

770

check(operation: string, node: object, parent: object, position: string|number, more?: object): boolean;

771

772

/**

773

* Get the last error that occurred

774

* @returns Error object or empty object

775

*/

776

last_error(): object;

777

778

/**

779

* Get a localized string

780

* @param key - String key to look up

781

* @returns Localized string

782

*/

783

get_string(key: string): string;

784

```

785

786

## Types

787

788

```javascript { .api }

789

interface jsTree {

790

// Instance properties

791

element: jQuery;

792

settings: object;

793

_id: number;

794

_cnt: number;

795

_data: object;

796

_wrk: Worker|null;

797

798

// All methods documented above are available on instances

799

}

800

801

// Static namespace properties

802

interface jstreeStatic {

803

version: string;

804

defaults: object;

805

plugins: object;

806

path: string;

807

idregex: RegExp;

808

root: string;

809

}

810

```