Created
January 15, 2010 06:47
-
-
Save quackingduck/277866 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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