Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data property not being updated while looping #127

Closed
Ehceyn opened this issue May 27, 2022 · 1 comment
Closed

Data property not being updated while looping #127

Ehceyn opened this issue May 27, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@Ehceyn
Copy link

Ehceyn commented May 27, 2022

I tried creating new qr codes while looping through an external data but the data is not being updated

` const data = ["uihiuh", "juuiiu", "huiiu", "uhui"];
const qrCode = [];
const container = document.getElementById("container");
data.forEach((qrInfo, i) => {
// Create Html
let div1 = document.createElement("div");
let div2 = document.createElement("div");
let button = document.createElement("button");
let div3 = document.createElement("div");
let div4 = document.createElement("div");
let div5 = document.createElement("div");
let article = document.createElement("article");
let p = document.createElement("p");

    div2.className = "flex flex-col items-center space-y-3";
    button.innerHTML = "Download";
    button.id = "download" + i;
    div3.className = "flex justify-center";
    div5.id = "canvas" + i;
    p.innerHTML = qrInfo;
    p.className = "font-extrabold text-sm text-center";
    article.append(p);

    div4.append(div5);
    div3.append(button);
    div2.append(div3);
    div2.append(div4);
    div2.append(article);
    container.append(div2);

    // Create canvas
    qrCode.push(
      new QRCodeStyling({
        width: 150,
        height: 150,
        type: "svg",
        data: qrInfo + i,
        image:
          "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
        dotsOptions: {
          color: "#000",
          type: "rounded",
        },
        backgroundOptions: {
          color: "#fff",
        },
        imageOptions: {
          crossOrigin: "anonymous",
          margin: 5,
        },
      })
    );
    console.log(qrCode);
    qrCode[i].append(document.getElementById("canvas" + i));
    // qrCode[i].download({ name: "qr", extension: "png" });
  });
`
@kozakdenys
Copy link
Owner

Hi @Ehceyn, it seems like a duplicate of #210

@kozakdenys kozakdenys added the duplicate This issue or pull request already exists label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants