Hi,
I have the following ajax example, with a list of counters, and two
buttons for adding/removing elements. The list is sortable.
There are two things that I don''t know how to do:
. remove an elemet
. when I add a new element to the list, that element doesn''t become
sortable with the rest of the list
Thanks,
hugo
#### View
<html>
<head>
<title>Ajax List Demo</title>
<%= javascript_include_tag :defaults %>
</head>
<body>
<%= form_remote_tag(:update => "list",
:url => { :action => :add_item },
:position => "bottom" ) %>
<%= text_field_tag :newitem %>
<%= submit_tag "Add item" %>
<%= end_form_tag %>
<%= form_remote_tag(:delete => "list",
:url => { :action => :cyaitem }) %>
<%= text_field_tag :cyaitem %>
<%= submit_tag "Remove item" %>
<%= end_form_tag %>
<ul id="list">
<% 6.times do |i| -%>
<li id="item_<%= i+1 %>">I''m number <%= i+1
%></li>
<% end -%>
</ul>
<%= sortable_element ''list'', :complete =>
visual_effect(:highlight,
''list'') %>
</body>
</html>
### Controller
def index
end
def add_item
render_text "<li id=\"item_7" +
"\">I''m number 7</li>"
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---