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

228
Visualizações
$(#id).html(content) function to set content to the next column

This is my HTML code:

  <div class="row margin-top-3">
    <div class="col-sm-7">
    <h2>NFTs</h2>
    <div class="table-responsive">
     <table class="table table-bordered">
     <thead>
      <tr>
      <th id = "NFTID">NFT ID</th>
      <th id = "NFTNAME">NFT Name</th>
      <th id = "NFTCREATOR">Creator</th>
      </tr>
     </thead>
     <tbody id="NFT-rows">
     </tbody>
     </table>
    </div>
    </div>
   </div>

The following three functions populate the table by column. The problem is that the third function overwrites the second column instead of the third column. Also, adding a fourth function will again overwrite the second column.

So, how can I re-write the $(#id).html(content) part to make it populate the next column instead of the second?

 setupNFTRows: function() {
  console.log("setupNFTrows NFT Array = " + JSON.stringify(NFTs));
  console.log("NFT = " + Object.keys(NFTs))
  Object.keys(NFTs).forEach(function (NFT) { 
    console.log("inside setupNFTrows");
   $("#NFT-rows").append("<tr><td>" + "NFT_ID_" + NFT + "</td><td id='" + NFTs[NFT] + "'></td></tr>");
  });
 },

 populateNFTNames: function() {
  console.log("inside populateNFTNames")
  let NFTIDs = Object.keys(NFTs);
  console.log("NFTIDs = " + NFTIDs)
  for(var i=0; i < NFTIDs.length; i++) {
    let nftid = NFTIDs[i];
    NFTContract.deployed().then(function(contractInstance) {
      contractInstance.getNFTname.call(nftid).then(function(v) {
        $("#" + NFTs[nftid]).html(v.toString());
      })
    })
  }
 },

 populateCreators: function() {
  let NFTIDs = Object.keys(NFTs);
  for(var i=0; i < NFTIDs.length; i++) {
    let nftid = NFTIDs[i];
    NFTContract.deployed().then(function(contractInstance) {
      contractInstance.getCreator.call(nftid).then(function(v) {
       $("#" + NFTs[nftid]).html(v.toString());
      })
    })
  }
 },

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is because data tables are populated a row at a time, not a column at a time. The best way to approach this would be to zip your data together into a cohesive set to fill the rows:

    const getNFTNames = (id) => {
      NFTContract.deployed().then(contractInstance => {
        contractInstance.getNFTname.call(nftid).then(v => {
          return v.toString();
        });
      });
    };

    const getCreators = (id) => {
      NFTContract.deployed().then(contractInstance => {
        contractInstance.getCreator.call(nftid).then(v => {
          return v.toString();
        });
      });
    };

    const setupNFTRows = () => {
      Object.keys(NFTs).forEach(id => {
       $("#NFT-rows").append(
        `<tr id='NFT_ID_${id}'>
          <td>NFT_ID_${id}</td>
          <td>${getNFTNames(id)}</td>
          <td>${getCreators(id)}</td>
         </tr>`);
      });
    };
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