Question
Button in plugin running JSX action
I im making simple plugin with buttons which can run photoshop actions, (removeBgBtn) works correct but two another button wont run, there is no error in logs. I have folder scripts and inside I have two jsx scripts. They works correct when I use classic action panel.
document.addEventListener("DOMContentLoaded", () => {
const removeBgBtn = document.getElementById("remove-bg-btn");
const smartBtn = document.getElementById("smartBtn");
const classicBtn = document.getElementById("classicBtn");
if (removeBgBtn) {
removeBgBtn.addEventListener("click", async () => {
console.log("Button clicked! Starting background removal process...");
try {
await remove_background();
alert("Background removed successfully!");
console.log("✅ Background removed successfully!");
} catch (error) {
console.error("❌ Error removing background:", error);
alert("Failed to remove background: " + (error.message || "Unknown error"));
}
});
}
if (smartBtn) {
smartBtn.addEventListener("click", async () => {
await runJSXScript("scripts/smart.jsx"); // Ensure the correct script path is used
});
}
if (classicBtn) {
classicBtn.addEventListener("click", async () => {
await runJSXScript("scripts/classic.jsx"); // Ensure the correct script path is used
});
}
});
