I just completed the peepcode tutorial on RJS (http://www.peepcode.com/articles/2006/08/13/rjs-templates) and am now refactoring things to work for tagging. I want to be able to pass comma or space seperated values from the text_field "name", to the controller and have it split up the values, insert them into the DB, pass them to create.rjs which will then insert them into the DOM as new elements.
I have it working for all strings, but can't seem to figure out get the controller to deal with spaces or commas. Any help I can get is appreciated!
---- FORM PARTIAL ----
<%= form_remote_tag :url => {:action => 'create'}, :html => {:id => 'task_form'} %>
<div>Add Task:</div> <label for="task_name">Name</label> <%= text_field 'task', 'name' %> <label for="task_value">Value</label> <%= text_field 'task', 'value' %>
<%= submit_tag 'Add New Task' %>
<%= end_form_tag %>
---- CONTROLLER -----
def create @task = Task.new params[:task] if @task.save calculate_totals render :action => 'create.rjs' else render :action => 'shared/error.rjs' end end
---- CREATE.RJS ----
page.insert_html :bottom, 'tasks', :partial => 'task', :locals => {:task => @task}
page['task_form'].reset
page.visual_effect :highlight, @task.dom_id, :startcolor => "'#FF3399'", :endcolor => "'#000000'"
page.call "set_class_name", @task.dom_id, 'tagsnew'
---- TASKS ROUTES HERE ----
<div id="tasks" style="width: 500px;"> <%= render :partial => 'task', :collection => @tasks %> </div>
---- TASK PARTIAL ----
<div id="<%= task.dom_id %>" class="tags">
<%= link_to_remote '<img src="/images/delete.gif">', :url => tasks_url(:action => 'destroy', :id => task.id) %> <%= task.name %> <small>(<%= task.value %>)</small> </div>