Created
February 4, 2014 02:23
-
-
Save chrisbuttery/8796421 to your computer and use it in GitHub Desktop.
Personal Details - component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PersonalDetailsForm = require('personal-details'); | |
var personalDetailsFormEl = document.querySelector('.js-personal-details-form'); | |
if(personalDetailsFormEl) { | |
var data = document.querySelector('.js-personal-details-data'); | |
new PersonalDetailsForm(personalDetailsFormEl, data); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/json" class="js-personal-details-data"> | |
@Html.Raw(Model.ToJson()) | |
</script> | |
<form class="js-personal-details-form">...</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reactive = require('reactive'); | |
var Observable = require('observable'); | |
var Form = require('form'); | |
function PersonalDetailsForm(el, data) { | |
this.el = el; | |
this.model = new Observable(); | |
this.model.set(JSON.parse(data.innerHTML)); | |
this.bindings = reactive(this.el, this.model, this); | |
this.form = new Form(this.el); | |
} | |
module.exports = PersonalDetailsForm; |
But other than that, looks smokin'!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/chrisbuttery/8796421#file-personal-details-index-js-L8
I'd probably parse it in
boot
so the view just gets an object of data.