Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

42%
+1 −2
Q&A How to invoke dialog modal from module instead of directly using the showModal() method

I need to have 2 different models to create projects and to-do lists. I've figured out, that for HTML there is only one dialog menu that can be invoked with window.dialog.showModal(); directly. So ...

0 answers  ·  posted 2mo ago by Sevenfold‭  ·  edited 27d ago by Andreas witnessed the end of the world today‭

Question javascript
#4: Post edited by user avatar Andreas witnessed the end of the world today‭ · 2024-11-25T16:50:54Z (27 days ago)
Remove fluff and minor writing improvements. The question still needs a bigger cleanup or rewrite.
  • How to invoke dialog modal from module instead of using directly showModal() method
  • How to invoke dialog modal from module instead of directly using the showModal() method
  • Good day! I need to have 2 different models to create projects and todo lists. I've figured out, that for HTML there is only one dialog menu that can be invoked with `window.dialog.showModal();` directly. So then, I've created dialogModule file to store dialog model code for project pop-up model. Here is the code inside this module:
  • ```
  • export const dialog = document.getElementById("project-dialog");
  • export const open = document.getElementById("open");
  • export const cancel = document.getElementById("cancel");
  • export const close = document.getElementById("close");
  • export let openModel = open.addEventListener("click", () => {
  • dialog.showModal();
  • });
  • export let cancelModel = cancel.addEventListener("click", () => {
  • dialog.close();
  • });
  • export let closeMondel = close.addEventListener("click", () => {
  • dialog.close();
  • });
  • ```
  • And when I want to invoke project model menu, nothing happens.
  • Function that supposes invoking model:
  • ```
  • import { dialog, open, openModel } from "./dialogModule";
  • function updateProjectItems(e) {
  • openModel;
  • const div = e.parentElement.parentElement.querySelector("div");
  • projectValue.value = div.innerText;
  • updateText = e.parentElement.parentElement.querySelector("div");
  • addProjectUpdate.setAttribute("onclick", "UpdateOnSelectionProjects()");
  • projectValue.focus();
  • }
  • ```
  • With updating todo list it has `window.dialog.showModal();`. It works fine:
  • ```
  • function UpdateToDoItems(e) {
  • if (
  • e.parentElement.parentElement.querySelector("div").style.textDecoration ===
  • ""
  • ) {
  • window.dialog.showModal();
  • const values = e.parentElement.parentElement.querySelectorAll("#values");
  • todoValue.value = values[0].innerText;
  • todoDescription.value = values[1].innerText;
  • todoDate.value = values[2].innerText;
  • todoPriority.value = values[3].innerText;
  • updateText = e.parentElement.parentElement.querySelectorAll("#values");
  • addUpdate.setAttribute("onclick", "UpdateOnSelectionItems()");
  • todoValue.focus();
  • }
  • }
  • ```
  • I use variable for projects to summon a pop-up menu, which is not working. What can I do to fix it?
  • Here is my full repo: [github repo](https://github.com/DanMarkov/todo-app)
  • I need to have 2 different models to create projects and to-do lists. I've figured out, that for HTML there is only one dialog menu that can be invoked with `window.dialog.showModal();` directly. So then, I've created a `dialogModule` file to store the dialog model code for the project pop-up model. Here is the code inside this module:
  • ```
  • export const dialog = document.getElementById("project-dialog");
  • export const open = document.getElementById("open");
  • export const cancel = document.getElementById("cancel");
  • export const close = document.getElementById("close");
  • export let openModel = open.addEventListener("click", () => {
  • dialog.showModal();
  • });
  • export let cancelModel = cancel.addEventListener("click", () => {
  • dialog.close();
  • });
  • export let closeMondel = close.addEventListener("click", () => {
  • dialog.close();
  • });
  • ```
  • When I try to invoke the project model menu, nothing happens.
  • The function that attempts invoking the model:
  • ```
  • import { dialog, open, openModel } from "./dialogModule";
  • function updateProjectItems(e) {
  • openModel;
  • const div = e.parentElement.parentElement.querySelector("div");
  • projectValue.value = div.innerText;
  • updateText = e.parentElement.parentElement.querySelector("div");
  • addProjectUpdate.setAttribute("onclick", "UpdateOnSelectionProjects()");
  • projectValue.focus();
  • }
  • ```
  • With updating todo list it has `window.dialog.showModal();`. It works fine:
  • ```
  • function UpdateToDoItems(e) {
  • if (
  • e.parentElement.parentElement.querySelector("div").style.textDecoration ===
  • ""
  • ) {
  • window.dialog.showModal();
  • const values = e.parentElement.parentElement.querySelectorAll("#values");
  • todoValue.value = values[0].innerText;
  • todoDescription.value = values[1].innerText;
  • todoDate.value = values[2].innerText;
  • todoPriority.value = values[3].innerText;
  • updateText = e.parentElement.parentElement.querySelectorAll("#values");
  • addUpdate.setAttribute("onclick", "UpdateOnSelectionItems()");
  • todoValue.focus();
  • }
  • }
  • ```
  • I use variable for projects to summon a pop-up menu, which is not working. What can I do to fix it?
#3: Nominated for promotion by user avatar Alexei‭ · 2024-11-03T07:34:54Z (about 2 months ago)
#2: Post edited by user avatar Sevenfold‭ · 2024-11-02T23:42:57Z (about 2 months ago)
  • Good day! I need to have 2 different models to create projects and todo lists. I've figured out, that for html there is only one dialog menu that can be invoked with `window.dialog.showModal();` directly. So then, I've created dialogModule file to store dialog model code for project pop-up model. Here is the code inside this module:
  • ```
  • export const dialog = document.getElementById("project-dialog");
  • export const open = document.getElementById("open");
  • export const cancel = document.getElementById("cancel");
  • export const close = document.getElementById("close");
  • export let openModel = open.addEventListener("click", () => {
  • dialog.showModal();
  • });
  • export let cancelModel = cancel.addEventListener("click", () => {
  • dialog.close();
  • });
  • export let closeMondel = close.addEventListener("click", () => {
  • dialog.close();
  • });
  • ```
  • And when I want to invoke project model menu, nothing happens.
  • Function that supposes invoking model:
  • ```
  • import { dialog, open, openModel } from "./dialogModule";
  • function updateProjectItems(e) {
  • openModel;
  • const div = e.parentElement.parentElement.querySelector("div");
  • projectValue.value = div.innerText;
  • updateText = e.parentElement.parentElement.querySelector("div");
  • addProjectUpdate.setAttribute("onclick", "UpdateOnSelectionProjects()");
  • projectValue.focus();
  • }
  • ```
  • With updating todo list it has `window.dialog.showModal();`:
  • ```
  • function UpdateToDoItems(e) {
  • if (
  • e.parentElement.parentElement.querySelector("div").style.textDecoration ===
  • ""
  • ) {
  • window.dialog.showModal();
  • const values = e.parentElement.parentElement.querySelectorAll("#values");
  • todoValue.value = values[0].innerText;
  • todoDescription.value = values[1].innerText;
  • todoDate.value = values[2].innerText;
  • todoPriority.value = values[3].innerText;
  • updateText = e.parentElement.parentElement.querySelectorAll("#values");
  • addUpdate.setAttribute("onclick", "UpdateOnSelectionItems()");
  • todoValue.focus();
  • }
  • }
  • ```
  • I use variable for projects to summon a pop-up menu, which is not working. What can I do to fix it?
  • Here is my full repo: [github repo](https://github.com/DanMarkov/todo-app)
  • Good day! I need to have 2 different models to create projects and todo lists. I've figured out, that for HTML there is only one dialog menu that can be invoked with `window.dialog.showModal();` directly. So then, I've created dialogModule file to store dialog model code for project pop-up model. Here is the code inside this module:
  • ```
  • export const dialog = document.getElementById("project-dialog");
  • export const open = document.getElementById("open");
  • export const cancel = document.getElementById("cancel");
  • export const close = document.getElementById("close");
  • export let openModel = open.addEventListener("click", () => {
  • dialog.showModal();
  • });
  • export let cancelModel = cancel.addEventListener("click", () => {
  • dialog.close();
  • });
  • export let closeMondel = close.addEventListener("click", () => {
  • dialog.close();
  • });
  • ```
  • And when I want to invoke project model menu, nothing happens.
  • Function that supposes invoking model:
  • ```
  • import { dialog, open, openModel } from "./dialogModule";
  • function updateProjectItems(e) {
  • openModel;
  • const div = e.parentElement.parentElement.querySelector("div");
  • projectValue.value = div.innerText;
  • updateText = e.parentElement.parentElement.querySelector("div");
  • addProjectUpdate.setAttribute("onclick", "UpdateOnSelectionProjects()");
  • projectValue.focus();
  • }
  • ```
  • With updating todo list it has `window.dialog.showModal();`. It works fine:
  • ```
  • function UpdateToDoItems(e) {
  • if (
  • e.parentElement.parentElement.querySelector("div").style.textDecoration ===
  • ""
  • ) {
  • window.dialog.showModal();
  • const values = e.parentElement.parentElement.querySelectorAll("#values");
  • todoValue.value = values[0].innerText;
  • todoDescription.value = values[1].innerText;
  • todoDate.value = values[2].innerText;
  • todoPriority.value = values[3].innerText;
  • updateText = e.parentElement.parentElement.querySelectorAll("#values");
  • addUpdate.setAttribute("onclick", "UpdateOnSelectionItems()");
  • todoValue.focus();
  • }
  • }
  • ```
  • I use variable for projects to summon a pop-up menu, which is not working. What can I do to fix it?
  • Here is my full repo: [github repo](https://github.com/DanMarkov/todo-app)
#1: Initial revision by user avatar Sevenfold‭ · 2024-11-01T23:55:07Z (about 2 months ago)
How to invoke dialog modal from module instead of using directly showModal() method
Good day! I need to have 2 different models to create projects and todo lists. I've figured out, that for html there is only one dialog menu that can be invoked with `window.dialog.showModal();` directly. So then, I've created dialogModule file to store dialog model code for project pop-up model. Here is the code inside this module:
```
export const dialog = document.getElementById("project-dialog");
export const open = document.getElementById("open");
export const cancel = document.getElementById("cancel");
export const close = document.getElementById("close");


export let openModel = open.addEventListener("click", () => {
    dialog.showModal();
});

export let cancelModel = cancel.addEventListener("click", () => {
    dialog.close();
});

export let closeMondel = close.addEventListener("click", () => {
    dialog.close();
});
```
And when I want to invoke project model menu, nothing happens.
Function that supposes invoking model:
```
import { dialog, open, openModel } from "./dialogModule";

function updateProjectItems(e) {
  openModel;
  const div = e.parentElement.parentElement.querySelector("div");
  projectValue.value = div.innerText;

  updateText = e.parentElement.parentElement.querySelector("div");
  addProjectUpdate.setAttribute("onclick", "UpdateOnSelectionProjects()");
  projectValue.focus();
}

```
With updating todo list it has `window.dialog.showModal();`:
```
function UpdateToDoItems(e) {
    if (
      e.parentElement.parentElement.querySelector("div").style.textDecoration ===
      ""
    ) {
      window.dialog.showModal();
      const values = e.parentElement.parentElement.querySelectorAll("#values");
      todoValue.value = values[0].innerText;
      todoDescription.value = values[1].innerText;
      todoDate.value = values[2].innerText;
      todoPriority.value = values[3].innerText;


      updateText = e.parentElement.parentElement.querySelectorAll("#values");
      addUpdate.setAttribute("onclick", "UpdateOnSelectionItems()");
      todoValue.focus();
    }
}
```
I use variable for projects to summon a pop-up menu, which is not working. What can I do to fix it?
Here is my full repo: [github repo](https://github.com/DanMarkov/todo-app)