I'm working on adding tagging to my application, to add tags to a mailing list of fans.
I've got checkboxes to select each fan, and a dropdown select list with the current tags and a "New tag" option. If you choose "New tag", a Javascript prompt asks you to name the new tag, and then it calls the method which adds the tags to the list of fans.
So far so good, but the last thing I want it to do is refresh the list of fans with the new tags applied. Right now it's refreshing the list of fans, except it's the previous list of fans without the new tags. If I manually reload the page, the tags are clearly there, but my guess is the inline RJS is happening too fast, so that it's refreshing the fans_list DIV before the new tags have been applied? I'm not sure.
Here's the function called from my form_observer:
FansController#new_tag
def new_tag if params[:tag] == "New tag" render :update do |page| session[:fans] = params[:fans] unless params[:fans].empty? page.call("x_add_tag") @fans = Fan.paginate :all, :per_page => 25, :page => params[:p], :order => "created_at DESC" page.replace_html 'fans_list', :partial => 'fans_list', :locals => {:fans => @fans, :what => "FUNK YEAH"} end end else render nil, :layout => false end end
What am I doing wrong? Thanks, Jeff