Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

274
Vistas
how to use variable in jstree data?

this is my code

var treedata = ['{ "id" : "ajson1", "parent" : "#", "text" : "Customer" }', 
   '{ "id" : "ajson2", "parent" : "ajson1", "text" : "Order number" }',
   '{ "id" : "ajson3", "parent" : "ajson1", "text" : "Date" }',      
   '{ "id" : "ajson4", "parent" : "#", "text" : "Company Name" }',
   '{ "id" : "ajson5", "parent" : "#", "text" : "Contact Name" }',
   '{ "id" : "ajson6", "parent" : "#", "text" : "Name1" }',
   '{ "id" : "ajson7", "parent" : "#", "text" : "Product number1" }'];

$('#data').jstree({
        'core' : {
            'data' : treedata 
        }
    });

but when i run it it do nothing but we i use this



$('#data').jstree({
        'core' : {
            'data' : {
                   ['{ "id" : "ajson1", "parent" : "#", "text" : "Customer" }', 
   '{ "id" : "ajson2", "parent" : "ajson1", "text" : "Order number" }',
   '{ "id" : "ajson3", "parent" : "ajson1", "text" : "Date" }',      
   '{ "id" : "ajson4", "parent" : "#", "text" : "Company Name" }',
   '{ "id" : "ajson5", "parent" : "#", "text" : "Contact Name" }',
   '{ "id" : "ajson6", "parent" : "#", "text" : "Name1" }',
   '{ "id" : "ajson7", "parent" : "#", "text" : "Product number1" }'];

}
        }
    });

it work so how can i use variable in data ??

i wanted to run first code but it is not working

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Do you mean that you want to use a variable for a property value?

If you just want to use the variable:

let n = 42;

const obj = {
  'id': n
}

If you want to place the variable within a string, any of the following works:

let name = 'Bob';

const obj = {
  'description1': `User, ${name}, is cool`,
  'description2': 'User, ' + name + ', is cool',
  'description3': 'User, '.concat(name, ', is cool')
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda