Skip to content

Commit

Permalink
New scoping tip.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnat authored Feb 25, 2024
1 parent 1e81764 commit 2102a39
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,11 @@ me().on("click", async event => {
* `e`, `ev`, `evt` = event
* `f`, `fn` = function

#### Scope new functions inside `<script>`
* ⭐ Inside an event: `me().on('click', ev => { /* add and call function here */ })`
#### Scope functions inside `<script>`
* ⭐ On `me()`
* `me().doIt = (message) => { alert(message) }`
* `me().on('click', (ev) => { me(ev).doIt("hello") })`
* ⭐ Or, in an event: `me().on('click', ev => { /* add and call function here */ })`
* Or, use an inline module: `<script type="module">`
* Note: `me()` will no longer see `parentElement` so explicit selectors are required: `me(".mybutton")`
* Or, use backend code to generate unique names for anything not scoped by `me()`
Expand Down

0 comments on commit 2102a39

Please sign in to comment.