elabs/serenade.js — Issue #14: Hooks to make two-way data binding possible
Author: augustl
Created: 2012-02-09 12:33:35+00:00
State: open

Given this view:

form[event:submit=submit]
p
label "Username"
input[type="text" value=@username]
p
label "Password"
input[type="password" value=@password]
input[type="submit" value="Log in"]

I would like to get access to the two input elements with relevant data in them. It is currently possible to hardcode event listeners, `input[type="text" value=@username event:change:onUsernameChange`, but that is very cumbersome.

A method to automatically provide two-way data binding would make this job easy. Perhaps a syntax like `input[type="text" name=@username]` could trigger that, setting the name attribute to "username", binding a change event that updates the model, and also setting value on the input element.