OK, I used the ID of the select and did a replace:
RJS:
page[:showcontact].hide
page[:contactlist].show
page.insert_html :bottom,‘contactlist’, :partial => ‘ajaxAddToMop’, :locals => {:contact => @contact }
page[:contact_id].replace :partial => “updateContactList”, :locals => {:contacts => @contacts, :mop => @mop }
Partial:
<%= select(‘contact’, ‘id’, @contacts, {:prompt => ‘Select Contact’} ,{ :onchange => remote_function(:url => { :controller => ‘contacts’, :action => “ajaxshowcontact”, :id => @mop.id},
:with => “‘contactid=’ + this.value” )
} ) %>
No change. Prompt is still not showing up. Data is there jsut not he prompt. I need the prompt as I use an ajax on change so the user can view/edit/update the user info if necessary inside the form. the controller code basically is updating the contact lsit.
1.Gets all contacts.
2. gets all contacts associated with the form
3. subtracts the two and givesme an array with the contacts not associated woit the form.
4. As I add users to the form I make the association to the form. This way I can update the list easier than keeping track of an array.
Here is the controller code, no real significance.
def ajaxAddToMop
@contact = Contact.find(params[:contact][:id], :include => [:company])
@mop = Mop.find(params[:id])
@mop.contacts << @contact
a = Contact.all.collect{|p| [ p.id ] }
b = @mop.contacts.all.collect{|p| [ p.id ] }
c = a-b
ar = Array.new
c.each{|arr|
arr.each{|p|
ar << p
}
}
@contacts = Contact.find(:all, :conditions => ["id IN (?)", ar]).collect {|p| [ [p.name](http://p.name), [p.id](http://p.id) ] }
end