Skip to content

Instantly share code, notes, and snippets.

@quackingduck
Created January 15, 2010 06:47
Show Gist options
  • Save quackingduck/277866 to your computer and use it in GitHub Desktop.
Save quackingduck/277866 to your computer and use it in GitHub Desktop.
view.Person = function() {
var
root = $.n('div.person'),
api = {},
ins = {},
n = function() { return $.fn.n.apply(root, arguments) };
// draw the view with the given attributes
api.init = function(attribs) {
n('form').n(function(n) {
n.txt('First Name:');
ins.firstName = n('input.first-name').val(attribs.first_name);
n.txt('Last Name:');
ins.lastName = n('input.last-name').val(attribs.last_name);
});
return api;
}
api.attribs = function() {
return {
first_name: ins.firstName.val(),
last_name: ins.lastName.val()
}
}
function greet() {
alert("Hello " + fullName());
}
function fullName() {
view.firstName() + " " + view.lastName();
}
return root.data('view',api);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment