Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vpj/weya
Simple Typescript/Javascript framework for DOM manipulation
https://github.com/vpj/weya
dom-manipulation html typescript ui-template
Last synced: 24 days ago
JSON representation
Simple Typescript/Javascript framework for DOM manipulation
- Host: GitHub
- URL: https://github.com/vpj/weya
- Owner: vpj
- License: mit
- Created: 2014-03-19T03:51:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-08-25T09:36:33.000Z (about 2 years ago)
- Last Synced: 2024-10-04T15:33:44.769Z (about 1 month ago)
- Topics: dom-manipulation, html, typescript, ui-template
- Language: TypeScript
- Homepage:
- Size: 114 KB
- Stars: 15
- Watchers: 5
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# 🐜 Weya
Weya is a lightweight library for DOM manipulation.
Here's a small example to show the usage.
```typescript
let userElems = []
$('div', '.users', document.body, $ => {
for (let i = 0; i < users.length; ++i) {
let userDiv = $('div', '.user', { on: { click: editUser } }, $ => {
let name = $('span', '.name', users[i])
let phone = $("span', '.phone", phones[i])
});
(userDiv).userId = i
userElems.push({ user: users[i], div: userDiv })
}
})
```The above code creates a list of users. It binds the data to the dom element `userDiv.userId = i` and also keeps track of all the DOM elements in `userElems`. This is important if you want to manipulate the DOM without reloading the entire user list, for example if a name of a user changes you could change it with `userElems[changedUserId].name.textContent = changedUserName`.