2
0
mirror of https://github.com/esiur/iui.git synced 2025-05-06 14:52:58 +00:00
iui/docs/md/getting-started/scripts.md
2021-11-15 00:11:12 +03:00

39 lines
914 B
Markdown

#Scripts
Scripts within tags are executed as functions with the scope varaiables and *this* argument is set to the parent element
<i-codepreview>
<button>
<script>
this.onclick = () => { alert("Hello World !")};
this.innerHTML = "Click me";
</script>
</button>
</i-codepreview>
When the function returns an object it will be projected to the parent element.
<i-codepreview>
<button>
<script>
this.onclick = () => { alert("Hello World !")};
return {innerHTML: "Click Me"}
</script>
</button>
</i-codepreview>
Scope variables example
<i-codepreview>
<button>
<script>
this.onclick = () => {
refs.msg.innerHTML = new Date().toTimeString();
};
return {innerHTML: "Click Me"}
</script>
</button>
<div ref="msg"></div>
</i-codepreview>