Commit 2b702c93 authored by Ryan Niemeyer's avatar Ryan Niemeyer

Use trim with polyfill.

parent 6bfa658c
(function () {
//trim polyfill
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
};
}
//a custom binding to handle the enter key (could go in a separate library)
ko.bindingHandlers.enterKey = {
init:function (element, valueAccessor, allBindingsAccessor, data) {
......@@ -78,7 +85,7 @@
//add a new todo, when enter key is pressed
self.add = function (data, event) {
var newTodo, current = (self.current() || "").replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g, "");
var newTodo, current = self.current().trim();
if (current) {
newTodo = new Todo(current);
self.todos.push(newTodo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment