Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

275
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda