Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.2 KB

File metadata and controls

59 lines (43 loc) · 1.2 KB

@ntix/binding

A small dom binder

github.com/ntix/binding

copied from github.com/MrAntix/bind

and converted to Deno deno.land

example

  

The button innerText property and click event are bound to a context as shown below, click the button to see it in action

<script type="module"> import { bind } from './mod.js' const context = { data: { text: 'click me' }, onClick: e => { e.stopPropagation(); context.data.text = 'thanks!'; setTimeout(() => { context.data.text = 'click me again'; }, 2000); } } bind(document, context); </script>
<button bind [inner-text]="data.text" {click}="onClick"></button>

<script type="module">
  import { bind } from './bind.js';

  const context = {
    text: 'click me',
    onClick: e => {
      e.stopPropagation();

      context.data.text = 'thanks!';
      setTimeout(() => {
        context.data.text = 'click me again';
      }, 2000);
    }
  };

  bind(document, context);
</script>