Skip to content

feat(tag): simulate onChange in Tag #899

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

reme3d2y
Copy link
Contributor

Тэг используется в формах как чекбокс\радиокнопка, но приходится делать обвязки, т.к. у него нет onChange, checked, value

@alfa-bot
Copy link
Collaborator

Собрана новая демка.

@alfa-bot
Copy link
Collaborator

Собрана новая демка.


if (onChange) {
const input = document.createElement('input');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А если так

 const input = document.createElement('input');
 input.type = "checkbox";
 input.name = name;
 if (typeof checked !== 'undefined') input.checked = payload.checked;
 if (typeof value !== 'undefined') input.value = value.toString();

  input.onchange = e => onChange(e, payload);

  input.click();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тогда ведь click-event будет, а не change

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants