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

Find out how to create DOM nodes more easily #221

Open
programarivm opened this issue Apr 22, 2024 · 0 comments
Open

Find out how to create DOM nodes more easily #221

programarivm opened this issue Apr 22, 2024 · 0 comments

Comments

@programarivm
Copy link
Member

programarivm commented Apr 22, 2024

At the moment, DOM nodes are being created programmatically using the mount() method defined in AbstractController, as it shown in the ExplainPositionModal component.

import Modal from 'bootstrap/js/dist/modal.js';
import AbstractComponent from '../AbstractComponent.js';

export class ExplainPositionModal extends AbstractComponent {
  mount() {
    const p = this.el.querySelector('p');
    p.replaceChildren();
    p.appendChild(document.createTextNode(this.props.explanation));
  }
}

export const explainPositionModal = new ExplainPositionModal(
  document.getElementById('explainPositionModal'),
  {
    modal: new Modal(document.getElementById('explainPositionModal')),
    explanation: ''
  }
);

However, creating DOM nodes might be simplified if JSX syntax or something similar could be used instead.

Happy learning!

@programarivm programarivm changed the title Find out how to mount DOM nodes more easily Find out how to create DOM nodes more easily Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant