1.6.13 • Published 6 years ago

live-dom v1.6.13

Weekly downloads
54
License
MIT
Repository
github
Last release
6 years ago

live-dom

DOM auto-discover library. Initialize matched nodes automatically.

ᴋɪʟᴛ ᴊs npm Build Status GitHub license

Installation

npm install live-dom --save

Usage

$live('.btn.submit-login', function (btn) {

  btn.addEventListener('click', function (e) {
    user.login();
  });

});

Forms

Initialize automatically html forms based on name attribute.

<form name="login">
  <input type="text" name="username"></input>
  <input type="password" name="password"></input>
</form>
$live.form('login', function (form) {

  form.addEventListener('submit', function (e) {
    fetch('/api/signin', {
      method: 'post',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        username: form.elements['username'].value,
        password: form.elements['password'].value,
      })
    });
  });

});

Components

$live.components implements a wrapper around customElements V1. Using customElements v0 or $live-dom as fallbacks.

$live.component('login-form', {
  template: `
    <form name="login">
      <input type="text" name="username"></input>
      <input type="password" name="password"></input>
    </form>
  `,
  controller: function (loginForm) {
    var form = loginForm.querySelector('form');

    form.addEventListener('submit', function (e) {
      fetch('/api/signin', {
        method: 'post',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          username: form.elements['username'].value,
          password: form.elements['password'].value,
        })
      });
    });
  }
});
1.6.13

6 years ago

1.6.12

6 years ago

1.6.11

6 years ago

1.6.10

6 years ago

1.6.9

6 years ago

1.6.8

7 years ago

1.6.7

7 years ago

1.6.6

7 years ago

1.6.5

7 years ago

1.6.4

7 years ago

1.6.3

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.5.21

7 years ago

1.5.20

7 years ago

1.5.19

7 years ago

1.5.18

7 years ago

1.5.16

7 years ago

1.5.15

7 years ago

1.5.14

7 years ago

1.5.13

7 years ago

1.5.12

7 years ago

1.5.11

7 years ago

1.5.10

7 years ago

1.5.9

7 years ago

1.5.8

7 years ago

1.5.7

7 years ago

1.5.6

7 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.4

7 years ago