Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
$(#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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!