Dynamically updating list


#1

hi every body. i am try to do example of agil books.dynamically updating
list of chapter 18.
1)this is my code for controller----
class ListnoajaxController < ApplicationController
def index
@items = Item.find_recent
end
def add_item
item = Item.new(params[:item_body])
render(:partial => “item”, :object => item)
end
def item
end
end
2)the code for item class in app/model
class Item < ActiveRecord::Base
attr_reader :body
attr_reader :posted_on
FAKE_DATABASE = []
def initialize(body)
@body = body
@posted_on = Time.now
FAKE_DATABASE.unshift(self)
end
def self.find_recent
FAKE_DATABASE
end

Populate initial items

new(“Feed cat”)
new(“Wash car”)
new(“Sell start-up to Google”)
end
3)now i make two template
1)index.rhtml
2)_item.rhtml
and the template code of index.rhtml is

My To Do List


the code for partial template _item.rhtml is

function item_added() {
var item = $(‘items’).firstChild;
new Effect.Highlight(item);
Element.hide(‘busy’);
$(‘form-submit-button’).disabled = false;
$(‘item-body-field’).value = ‘’;
Field.focus(‘item-body-field’);
}
function item_loading() {
$(‘form-submit-button’).disabled = true;
Element.show(‘busy’);
}

‘item’, :collection => @items) %>

{ :action => “add_item” },
:update => “items”,
:position => :top,
:loading => ‘item_loading()’,
:complete => ‘item_added()’) %>
‘item-body-field’) %>
‘form-submit-button’) %>
Adding…


now i am refercing my page
http://127.0.0.1:3000/listnoajax/index
but it shows blank page
so plese any body tell me how i do that example.
thanx in advance