What measures can be taken to prevent the reloading of a subfolder within the same parent in the Fuel

var DataSourceTree = function (options) {
                this.source = options.source;
            }
            DataSourceTree.prototype = {
                data: function (options, callback) {
                    var self = this;
                    var $data = null;
                    var param = null
                    if (!("name" in options) && !("type" in options)) {
                        param = 0; //load the first level  
                    } else if ("type" in options && options.type == "folder") {
                        if ("additionalParameters" in options && "children" in options.additionalParameters) {
                            param = options.additionalParameters["id"];
                        }
                    }
                    if (param != null) {
                        $.ajax({
                            source: this.source,
                            data: 'id=' + param,
                            type: 'POST',
                            dataType: 'json',
                            success: function (response) {
                                callback(response)
                            },
                            error: function (response) {
                                console.log(response);
                            }
                        })
                    }
                }
            };
            $('#tree2').admin_tree({
                dataSource: new DataSourceTree({ source: 'AccountTree.ashx' }),
                loadingHTML: '<div class="tree-loading"><i class="fa fa-spinner fa-2x fa-spin"></i></div>',
                'open-icon': 'fa-folder-open',
                'close-icon': 'fa-folder',
                'selectable': false,
                'multiSelect': false,
                'selected-icon': null,
                'unselected-icon': null
            });

this JSON data i revived from AccountTree.ashx {\"data\":[{\"id\":1,\"name\":\"label 1\",\"type\":\"folder\",\"additionalParameters\":{\"id\":1,\"children\":true,\"itemSelected\":false,\"name\":\"test\",\"type\":\"item\"}}]}

i know there is a problem in the callback(response)

https://i.sstatic.net/6DEtr.png

must be label1 --> item

Answer №1

Your data source function may need to update the URL for fetching JSON data.

Make sure to utilize the attr key and the event opened.fu.tree to assign data attributes to your nodes. These attributes can then be used to guide your data source in determining the correct URL and JSON to load.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the depths of JavaScript JSON elements

After processing my PHP code, it generates a JSON output that contains multiple entries in the same structure. Here is an example with two entries: { "0": { "campaign_id": "31", "title": "new title", "description": "new descrip ...

Error importing React Icons with the specific icon FiMoreHorizontal

Currently following a guide to create a Twitter-like application and I need to add the following imports: import { FiMoreHorizontal } from 'react-icons/fi' 2.3K (gzipped: 1K) import { VscTwitter } from 'react-icons/vsc' 3.1K (gzipped: ...

Does the positive Z axis move inward in threejs? The behavior of camera.near and camera.far seems strange

My goal is to display only a slice of my 3D object. I have tried setting the orthographic camera's camera.near to 2.0 and camera.far to 1.5, then iterating with values of camera.near = 1.5 and camera.far = 1.0. However, this approach is not yielding t ...

What is the best way to call an Angular component function from a global function, ensuring compatibility with IE11?

Currently, I am facing a challenge while integrating the Mastercard payment gateway api into an Angular-based application. The api requires a callback for success and error handling, which is passed through the data-error and data-success attributes of the ...

Tips for transferring state value from a form to a child modal

As a newcomer to React, I am uncertain about the best approach to take in my project. Specifically, I have a modal component that should appear once the user fills out a form and clicks on the Preview Voucher button to display the entered values. Below, yo ...

When attempting to send data using jQuery to PHP, an issue arises where PHP is unable to receive the information, resulting in an undefined variable

Has anyone successfully sent data from an HTML select to a PHP file using jQuery? I've tried multiple solutions suggested here, but none seem to be working for me. Below is the code I'm using: <select id="city" name="city" > <optgro ...

Error: The TVJS Framework encountered a JSON Parse issue due to an unexpected EOF

I am currently developing a TVML application specifically for Apple TV. However, when I attempt to execute this code to send a request to a remote server, I encounter the following error: SyntaxError: JSON Parse error: Unexpected EOF. My goal is to run thi ...

To successfully process this file type in JavaScript, you might require a suitable loader

Currently, I am facing an issue with my MVC application while trying to integrate Bootstrap 5 using Webpack. Despite attempting various workarounds with stage-0, stage-2, and stage-3, none have proven successful for me. I suspect that the problem lies wit ...

getting the child td element within a tr using a variable that changes dynamically

I'm facing an issue where I am trying to access the <td> of a <tr> using the jQuery .eq() function. The code snippet below illustrates what I am attempting: var foundElement = 3; var values = $(this).children("td:nth-child('" + foun ...

Guide to Generating Extern for a Constant Variable in Google Closure Compiler (Variable Cannot be Renamed due to Eval)

Currently, I am using Google Closure Compiler in "SIMPLE_OPTIMIZATIONS" mode for my JavaScript code. However, I encountered an issue when the obfuscation changed the variable name from "_u" to "a", resulting in an error that "_u" is not defined in the cons ...

Converting Markdown to HTML using AngularJS

I'm utilizing the Contentful API to retrieve content. It comes in the form of a JSON object to my Node server, which then forwards it to my Angular frontend. This JSON object contains raw markdown text that has not been processed yet. For instance, t ...

Identify Horizontal Swipe Gestures on Page-level

I am currently focused on ensuring accessibility for users utilizing voiceover technology. While navigating their phone, these individuals rely on right and left swipes to interact with elements on a page. I am seeking to implement swipe detection at the ...

Unspecified data output from jquery datepicker

I am currently utilizing a datepicker to select a date. I have implemented the jQuery datepicker, however, it is returning an undefined value. Can someone please assist me with this issue? My HTML CODE: <input type="text" class="form-control fromdate" ...

Using Jquery Chosen Plugin to Dynamically Populate One Chosen Selection Based on Another

Good evening to all, please excuse any errors in my English. I have successfully integrated a jQuery Chosen plugin with my 'estado' field (or province). My goal is to populate another jQuery Chosen plugin with the cities corresponding to that s ...

Learning how to access JavaScript variables within a Ruby on Rails view

Our team has been working on a javascript code that captures the URL of a selected image and stores it in a JavaScript variable called "src". The goal is to access this variable within a Rails view in order to obtain the ID of the selected image. We attemp ...

The onChange event seems to be failing to activate during a jQuery / Ajax form submission

Differences in Form Submission Methods The onChange event functions correctly with the traditional Type and Action method in both Firefox and Chrome. <form name="frmname" action="./add_p.php" method="POST"> <div> <select name=" ...

Implementing dynamic image insertion on click using a knockout observable

I'm utilizing an API to retrieve images, and I need it to initially load 10 images. When a button is clicked, it should add another 10 images. This is how I set it up: Defining the observable for the image amount: public imageAmount: KnockoutObserva ...

What is the best way to show an image within a div using HTML and fetching data from an API response?

I am attempting to showcase an image within a div using HTML. I utilized fetch to retrieve the JSON data from the following API: . The response contains JSON data with the image URL labeled "primaryImage". While I can display it as text, I am encounterin ...

Enhanced pages compilation in asp.net framework

In order to maintain consistent loading times for the website, it is important to ensure that updating individual pages does not impact the performance of other pages. Option A: Develop the application as a Web site project. After completion, transfer the ...

Comparing parameters between two functions in Javascript: a step-by-step guide

I am currently working on solving this problem: var name; var totalScore; var gamesPlayed; var player; var score; // Creating the game player object function makeGamePlayer(name, totalScore, ga ...