From 74ec1e5086bcf46a63e552057234d37806b98a8b Mon Sep 17 00:00:00 2001 From: fancyoung Date: Wed, 29 Aug 2012 16:04:54 +0800 Subject: [PATCH] Update examples/todos/todos.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix js bug: Uncaught TypeError: Cannot read property 'localStorage' of undefined  --- examples/todos/todos.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/todos/todos.js b/examples/todos/todos.js index 098d6cf82..f4f1f31c9 100644 --- a/examples/todos/todos.js +++ b/examples/todos/todos.js @@ -131,9 +131,12 @@ $(function(){ // Close the `"editing"` mode, saving changes to the todo. close: function() { var value = this.input.val(); - if (!value) this.clear(); - this.model.save({title: value}); - this.$el.removeClass("editing"); + if (!value){ + this.clear(); + }else{ + this.model.save({title: value}); + this.$el.removeClass("editing"); + } }, // If you hit `enter`, we're through editing the item.