  function _S4(){
    return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
  }

  function _guid(){
    return (_S4()+_S4()+"-"+_S4()+"-"+_S4()+"-"+_S4()+"-"+_S4()+_S4()+_S4());
  }

  function _indexPop(key) {
      localStorage.removeItem(key);
      k = key;
       var index = this._indexGet();
       var position = index.indexOf(key);
       if(position != -1){
      index = index.filter(function(val) {return val != key.toString()});
         }
         this._indexSet(index);
  }

   function _indexGet() {
       var index = this._storeGet('index');
       return index ? index : [];
     }

    function _indexAdd(key){
      var index = this._indexGet();
    index.push(key);
      this._indexSet(index);
    }

    function _indexSet(index) {
      localStorage.setItem('index', JSON.stringify(index));
    }

    function _getAll() {
      var r = [];
      var keys = this._indexGet();
      for (var i = 0 ; i < keys.length ; i++){ 
        var rv = this._storeGet(keys[i]);
        if (rv != undefined) r.push(rv);
      }
      return r
    }

    function _storeGet(key){
      try{
        return JSON.parse(localStorage.getItem(key));
      } catch(e){
        alert('ohhh my gosh! you tried to get and parse an invalid record! check your json.');
        return false
      }
    }

    function _storeSet(key,value){
      localStorage.setItem(key, JSON.stringify(value));
      this._indexAdd(key);
    }
        

  var List = Backbone.Collection.extend({
    model: Item
  });

  index = _indexGet();
  
  
  var ItemView = Backbone.View.extend({
    tagName: 'li',      
    events: { 
      'click span.delete': 'remove'
    },    
    initialize: function(){
      _.bindAll(this, 'render', 'unrender', 'remove');
      this.model.bind('remove', this.unrender);
    },
    render: function(){
      $(this.el).html('<span style="color:black;">'+this.model.get('Todo')+'<span class="delete">[X]</span><span class="edit">[EDIT]</span>');
      return this; 
    },
    unrender: function(){
      $(this.el).remove();
    },
    remove: function(){
      var id = this.model.get('id_todo');
      _indexPop(id);
      this.model.destroy();
    },

  });

  var ListView = Backbone.View.extend({
    el: $('body'), 
    events: {
      'keypress input#add': 'addItem'
    },
    initialize: function(){
      _.bindAll(this, 'render', 'addItem', 'appendItem'); 
      this.collection = new List();
      this.collection.bind('add', this.appendItem); 
      this.render();
    },

    count: function(){
      this.collection.add(_getAll())
    },


    render: function(){
      $(this.el).append("<input id='add'></input>");
      $(this.el).append("<ul></ul>");
      _(this.collection.models).each(function(item){
        appendItem(item);
      }, this);
      this.count();
    },

    addItem: function(){
      if (event.keyCode == 13 && add.value!=''){
        var item = new Item();
        item.set({
          id_todo: _guid(),
          Todo: add.value
        });
        item.save();
        this.collection.add(item);
        add.value = '';
      }
    },


    appendItem: function(item){
      var itemView = new ItemView({
        model: item
      });
      $('ul', this.el).append(itemView.render().el);
    }
  });

@@ -1654,16 +1654,91 @@
 'remove'
+,%0A      'click span.edit': 'edit',%0A      'keypress input#modify': 'modItem'
 %0A    %7D, 
@@ -2250,24 +2250,550 @@
 oy();%0A    %7D,
+%0A    edit: function()%7B%0A      $(this.el).html(%22%3Cinput id='modify'%3E%3C/input%3E%22);%0A    %7D,%0A    modItem: function()%7B%0A      if (event.keyCode == 13 && modify.value!='')%7B%0A        var val = modify.value;%0A        var id = this.model.get('id_todo');%0A        var item = new Item();%0A        item.set(%7B%0A          id_todo: id,%0A          Todo: val%0A        %7D);%0A        _indexPop(id);%0A        item.save();%0A      $(this.el).html('%3Cspan style=%22color:black;%22%3E'+val+'%3Cspan class=%22delete%22%3E%5BX%5D%3C/span%3E%3Cspan class=%22edit%22%3E%5BEDIT%5D%3C/span%3E');%0A      %7D   %0A    %7D
 %0A%0A  %7D);%0A%0A  v

edit functions on views