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

194
Views
How save multiple js objects in SessionStorage?

I'm trying to send objects in a sessionStorage with a button calls ".buttonClipboard". But only send one. I want send more objects from the table.

This is the code:

$('#buttonsDocumentation .buttonClipboard').on('click', function(){
    clipboard = JSON.parse(sessionStorage.getItem("clipboard"));
    if($.inArray(rowSelected[0], clipboard) < 0){
        if(clipboard == null){
            clipboard = [];
        }
        clipboard.push(rowSelected[0]);
        sessionStorage.setItem('clipboard', JSON.stringify(clipboard));
    }
    testClipboard();
}); 

How is it?

PD: rowSelected[0] is like id from object row.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I have an alternative, but only works in one table (tabDocument) instead of two (tabSearch):

$('#buttonsDocumentacion .botonClipboard').on('click', function(){
    var idsClip=[];
    if(clipboard = tableDocument.rows('.selected').data()){
        for(var i=0; i<clipboard.length; i++){
            idsClip.push(clipboard[i][0]);
        }   
    }
    sessionStorage.setItem('clipboard', JSON.stringify(idsClip));
    compruebaClipboard();
})
about 4 years ago · Juan Pablo Isaza Report

0

To add multiple selected rows to the clipboard, you need to send all of them in push(), not just selectedRow[0]. You can use spread syntax for this:

clipboard.push(...selectedRow);
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!