Skip to content

Instantly share code, notes, and snippets.

@imkost
Last active November 18, 2016 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imkost/e083d7e9ac8db22eb8f0171da16963cf to your computer and use it in GitHub Desktop.
Save imkost/e083d7e9ac8db22eb8f0171da16963cf to your computer and use it in GitHub Desktop.
function NameEditor({ instanceIndex }) {
return `
<div class="nameEditor">
<div>Enter you name:</div>
<input onKeyUp="NameEditor.onKeyUp(this, ${instanceIndex})" />
<div>
Hello, <span id="nameEditor__name-${instanceIndex}"></span>
</div>
</div>
`;
}
NameEditor.onKeyUp = (input, instanceIndex) => {
document.getElementById(`nameEditor__name-${instanceIndex}`).innerText = input.value;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment