I’m trying to develop a simple to-do list to learn RJS.
Thigns are working fine as long as I add new items. Let’s say I have
three
items.
item 1 - delete
item 2 - delete
item 3 - delete
When I click delete on the item2 to delete it, the items does get
deleted.
But that row becomes empty. The item 3 doesn’t get pushed up.
Does it mean that I should render the whole page or is there something
I’m
missing.
Here is my code to execute delete.
def remove_line
render :update do |page|
id = @params[:id]
span_name = ‘line-’ + id.to_s # delete line-2 for testing
page[span_name].remove
end
end
I also tried page[span_name].delete but no result.
When I look into firebug , in both the cases I see the element 'line-2"
there. It means when I ask line-2 to be removed, the line-2 is not
actually
removed. The browser just hides it and replaces the space by white
space.
Any help.