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

229
Vistas
$(#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 Respuestas
Responde la pregunta

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 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