I have this select in a form: <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select Contact''} , { :onchange => remote_function(:url => { :controller => ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, :with => "''contactid='' + this.value" ) } ) %> The prompt works in the form but when I do a replace_html on it I get everything but the prompt. Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Me wrote:> I have this select in a form: > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select Contact''} , > { :onchange => remote_function(:url => { :controller => > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, :with => > "''contactid='' + this.value" ) > } ) %> > > The prompt works in the form but when I do a replace_html on it I get > everything but the prompt.Post the replace_html code? Next, put only that <%= select %> thing into a partial (yes tiny otherwise useless partials are a Best Practice), then do rjs.replace_html :my_div, :partial => ''my_partial''. (I call "rjs" the variable everyone else calls "page", because the interthing has too many "page" variables all over it!) You could also see about putting the :url into a named route. Just about anything in Rails that''s "named" is a best practice, too! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ok, that select I put is the only thing in the partial. Here is the rjs: page[:contact_list].replace_html :partial => ''updateContactList'', :locals => { :contact => @contact } On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Me wrote: > > I have this select in a form: > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select Contact''} , > > { :onchange => remote_function(:url => { :controller => > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, :with => > > "''contactid='' + this.value" ) > > } ) %> > > > > The prompt works in the form but when I do a replace_html on it I get > > everything but the prompt. > > Post the replace_html code? > > Next, put only that <%= select %> thing into a partial (yes tiny otherwise > useless partials are a Best Practice), then do rjs.replace_html :my_div, > :partial => ''my_partial''. (I call "rjs" the variable everyone else calls > "page", > because the interthing has too many "page" variables all over it!) > > You could also see about putting the :url into a named route. Just about > anything in Rails that''s "named" is a best practice, too! > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hmm, hope you can post up more code, even from your controller as well. I think that instead of replacing the entire select tag, you can simply replace its contents. Firstly, give the select tag an id so that in your RJS, you can replace_html with options_for_select or whatever function you might want to use. On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok, that select I put is the only thing in the partial. > Here is the rjs: > page[:contact_list].replace_html :partial => ''updateContactList'', :locals => > { :contact => @contact } > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Me wrote: > > > I have this select in a form: > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select Contact''} , > > > { :onchange => remote_function(:url => { :controller => > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, :with => > > > "''contactid='' + this.value" ) > > > } ) %> > > > > The prompt works in the form but when I do a replace_html on it I get > > > everything but the prompt. > > > Post the replace_html code? > > > Next, put only that <%= select %> thing into a partial (yes tiny otherwise > > useless partials are a Best Practice), then do rjs.replace_html :my_div, > > :partial => ''my_partial''. (I call "rjs" the variable everyone else calls > > "page", > > because the interthing has too many "page" variables all over it!) > > > You could also see about putting the :url into a named route. Just about > > anything in Rails that''s "named" is a best practice, too! > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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, p.id ] } end On Sat, Apr 11, 2009 at 11:42 AM, Jaryl Sim <quantum.crusade-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > Hmm, hope you can post up more code, even from your controller as > well. > > I think that instead of replacing the entire select tag, you can > simply replace its contents. Firstly, give the select tag an id so > that in your RJS, you can replace_html with options_for_select or > whatever function you might want to use. > > On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Ok, that select I put is the only thing in the partial. > > Here is the rjs: > > page[:contact_list].replace_html :partial => ''updateContactList'', :locals > => > > { :contact => @contact } > > > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Me wrote: > > > > I have this select in a form: > > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select Contact''} > , > > > > { :onchange => remote_function(:url => { :controller => > > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, :with => > > > > "''contactid='' + this.value" ) > > > > } ) %> > > > > > > The prompt works in the form but when I do a replace_html on it I get > > > > everything but the prompt. > > > > > Post the replace_html code? > > > > > Next, put only that <%= select %> thing into a partial (yes tiny > otherwise > > > useless partials are a Best Practice), then do rjs.replace_html > :my_div, > > > :partial => ''my_partial''. (I call "rjs" the variable everyone else > calls > > > "page", > > > because the interthing has too many "page" variables all over it!) > > > > > You could also see about putting the :url into a named route. Just > about > > > anything in Rails that''s "named" is a best practice, too! > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ok this is weird, I have full CRUD working for my contacts table all doing ajax inline in my form. the odd one is that my delete funtion uses the same partial as the one above and when I do the rjs for the update on the select it DOES give me the "Prompt" to select User. Delete is the only one that the prompt actually comes back on. Same partial used on all of the updates to the contact select. On Apr 11, 12:26 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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, p.id ] } > end > > On Sat, Apr 11, 2009 at 11:42 AM, Jaryl Sim <quantum.crus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > > > > Hmm, hope you can post up more code, even from your controller as > > well. > > > I think that instead of replacing the entire select tag, you can > > simply replace its contents. Firstly, give the select tag an id so > > that in your RJS, you can replace_html with options_for_select or > > whatever function you might want to use. > > > On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Ok, that select I put is the only thing in the partial. > > > Here is the rjs: > > > page[:contact_list].replace_html :partial => ''updateContactList'', :locals > > => > > > { :contact => @contact } > > > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Me wrote: > > > > > I have this select in a form: > > > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select Contact''} > > , > > > > > { :onchange => remote_function(:url => { :controller => > > > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, :with => > > > > > "''contactid='' + this.value" ) > > > > > } ) %> > > > > > > The prompt works in the form but when I do a replace_html on it I get > > > > > everything but the prompt. > > > > > Post the replace_html code? > > > > > Next, put only that <%= select %> thing into a partial (yes tiny > > otherwise > > > > useless partials are a Best Practice), then do rjs.replace_html > > :my_div, > > > > :partial => ''my_partial''. (I call "rjs" the variable everyone else > > calls > > > > "page", > > > > because the interthing has too many "page" variables all over it!) > > > > > You could also see about putting the :url into a named route. Just > > about > > > > anything in Rails that''s "named" is a best practice, too! > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Not able to understand the flow of control. What is mop? Could you explain a bit further? This is interesting.. On Apr 12, 3:13 am, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok this is weird, I have full CRUD working for my contacts table all > doing ajax inline in my form. the odd one is that my delete funtion > uses the same partial as the one above and when I do the rjs for the > update on the select it DOES give me the "Prompt" to select User. > Delete is the only one that the prompt actually comes back on. Same > partial used on all of the updates to the contact select. > > On Apr 11, 12:26 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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, p.id ] } > > end > > > On Sat, Apr 11, 2009 at 11:42 AM, Jaryl Sim <quantum.crus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > > > Hmm, hope you can post up more code, even from your controller as > > > well. > > > > I think that instead of replacing the entire select tag, you can > > > simply replace its contents. Firstly, give the select tag an id so > > > that in your RJS, you can replace_html with options_for_select or > > > whatever function you might want to use. > > > > On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Ok, that select I put is the only thing in the partial. > > > > Here is the rjs: > > > > page[:contact_list].replace_html :partial => ''updateContactList'', :locals > > > => > > > > { :contact => @contact } > > > > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Me wrote: > > > > > > I have this select in a form: > > > > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select Contact''} > > > , > > > > > > { :onchange => remote_function(:url => { :controller => > > > > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, :with => > > > > > > "''contactid='' + this.value" ) > > > > > > } ) %> > > > > > > > The prompt works in the form but when I do a replace_html on it I get > > > > > > everything but the prompt. > > > > > > Post the replace_html code? > > > > > > Next, put only that <%= select %> thing into a partial (yes tiny > > > otherwise > > > > > useless partials are a Best Practice), then do rjs.replace_html > > > :my_div, > > > > > :partial => ''my_partial''. (I call "rjs" the variable everyone else > > > calls > > > > > "page", > > > > > because the interthing has too many "page" variables all over it!) > > > > > > You could also see about putting the :url into a named route. Just > > > about > > > > > anything in Rails that''s "named" is a best practice, too!--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well it is a telecom thing. If you perform maintenance on equipment then you need a form explaining what to do and how to do it. Anyway, the partial gives me a "prompt" if I do a delete or if I remove the contact from the form I also do a replace like on an New contact and it does give me a prompt. If I do a "New" contact or "edit" I do not get a "prompt" in the select. all CRUD operations use the same partial to update the select, doing ajax inline with the form. On Sun, Apr 12, 2009 at 11:26 PM, Ram <yourstruly.vinay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Not able to understand the flow of control. > What is mop? Could you explain a bit further? This is interesting.. > > On Apr 12, 3:13 am, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Ok this is weird, I have full CRUD working for my contacts table all > > doing ajax inline in my form. the odd one is that my delete funtion > > uses the same partial as the one above and when I do the rjs for the > > update on the select it DOES give me the "Prompt" to select User. > > Delete is the only one that the prompt actually comes back on. Same > > partial used on all of the updates to the contact select. > > > > On Apr 11, 12:26 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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, p.id ] } > > > end > > > > > On Sat, Apr 11, 2009 at 11:42 AM, Jaryl Sim <quantum.crus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > >wrote: > > > > > > Hmm, hope you can post up more code, even from your controller as > > > > well. > > > > > > I think that instead of replacing the entire select tag, you can > > > > simply replace its contents. Firstly, give the select tag an id so > > > > that in your RJS, you can replace_html with options_for_select or > > > > whatever function you might want to use. > > > > > > On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Ok, that select I put is the only thing in the partial. > > > > > Here is the rjs: > > > > > page[:contact_list].replace_html :partial => ''updateContactList'', > :locals > > > > => > > > > > { :contact => @contact } > > > > > > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > > > > Me wrote: > > > > > > > I have this select in a form: > > > > > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select > Contact''} > > > > , > > > > > > > { :onchange => remote_function(:url => { :controller => > > > > > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, > :with => > > > > > > > "''contactid='' + this.value" ) > > > > > > > } ) %> > > > > > > > > > The prompt works in the form but when I do a replace_html on it > I get > > > > > > > everything but the prompt. > > > > > > > > Post the replace_html code? > > > > > > > > Next, put only that <%= select %> thing into a partial (yes tiny > > > > otherwise > > > > > > useless partials are a Best Practice), then do rjs.replace_html > > > > :my_div, > > > > > > :partial => ''my_partial''. (I call "rjs" the variable everyone > else > > > > calls > > > > > > "page", > > > > > > because the interthing has too many "page" variables all over > it!) > > > > > > > > You could also see about putting the :url into a named route. > Just > > > > about > > > > > > anything in Rails that''s "named" is a best practice, too! > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I meant the flow of control in the code. From the view to the controller action, to the RJS and back to the view. I dont see a call to ajaxAddToMop. What are the names of the files with the RJS and the select_box?>if I do a delete or if I remove the >contact from the form I also do a replace like on an New contact and it does >give me a prompt. If I do a "New" contact or "edit" I do not get a >"prompt" in the select.I personally cant understand that. On Apr 13, 9:47 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well it is a telecom thing. If you perform maintenance on equipment then > you need a form explaining what to do and how to do it. > > Anyway, the partial gives me a "prompt" if I do a delete or if I remove the > contact from the form I also do a replace like on an New contact and it does > give me a prompt. If I do a "New" contact or "edit" I do not get a > "prompt" in the select. all CRUD operations use the same partial to update > the select, doing ajax inline with the form. > > On Sun, Apr 12, 2009 at 11:26 PM, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Not able to understand the flow of control. > > What is mop? Could you explain a bit further? This is interesting.. > > > On Apr 12, 3:13 am, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Ok this is weird, I have full CRUD working for my contacts table all > > > doing ajax inline in my form. the odd one is that my delete funtion > > > uses the same partial as the one above and when I do the rjs for the > > > update on the select it DOES give me the "Prompt" to select User. > > > Delete is the only one that the prompt actually comes back on. Same > > > partial used on all of the updates to the contact select. > > > > On Apr 11, 12:26 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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, p.id ] } > > > > end > > > > > On Sat, Apr 11, 2009 at 11:42 AM, Jaryl Sim <quantum.crus...@gmail.com > > >wrote: > > > > > > Hmm, hope you can post up more code, even from your controller as > > > > > well. > > > > > > I think that instead of replacing the entire select tag, you can > > > > > simply replace its contents. Firstly, give the select tag an id so > > > > > that in your RJS, you can replace_html with options_for_select or > > > > > whatever function you might want to use. > > > > > > On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Ok, that select I put is the only thing in the partial. > > > > > > Here is the rjs: > > > > > > page[:contact_list].replace_html :partial => ''updateContactList'', > > :locals > > > > > => > > > > > > { :contact => @contact } > > > > > > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > > > > > Me wrote: > > > > > > > > I have this select in a form: > > > > > > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select > > Contact''} > > > > > , > > > > > > > > { :onchange => remote_function(:url => { :controller => > > > > > > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, > > :with => > > > > > > > > "''contactid='' + this.value" ) > > > > > > > > } ) %> > > > > > > > > > The prompt works in the form but when I do a replace_html on it > > I get > > > > > > > > everything but the prompt. > > > > > > > > Post the replace_html code? > > > > > > > > Next, put only that <%= select %> thing into a partial (yes tiny > > > > > otherwise > > > > > > > useless partials are a Best Practice), then do rjs.replace_html > > > > > :my_div, > > > > > > > :partial => ''my_partial''. (I call "rjs" the variable everyone > > else > > > > > calls > > > > > > > "page", > > > > > > > because the interthing has too many "page" variables all over > > it!) > > > > > > > > You could also see about putting the :url into a named route. > > Just > > > > > about > > > > > > > anything in Rails that''s "named" is a best practice, too!--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ok, you asked what a mop was. ajaxAddtoMop just makes the association between the contact and form then updates the select removing the user from the select box. I have quite a few rjs and partials to make the full CRUD operations working ajax wise inline in the form. I can go offline if you really want to know all of the files being used, kinda lengthy here. The same partial is used between all actions doing a replace :partial. Just odd that only a couple of the functions give me the prompt. Basically it is really just a contact to form relationship. I may be using this same thing down the road I am sure. All of the new,edit,update,deletes of users are right in the form. Kinda cool really. On Mon, Apr 13, 2009 at 12:00 AM, Ram <yourstruly.vinay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I meant the flow of control in the code. > From the view to the controller action, to the RJS and back to the > view. > I dont see a call to ajaxAddToMop. > What are the names of the files with the RJS and the select_box? > > >if I do a delete or if I remove the > >contact from the form I also do a replace like on an New contact and it > does > >give me a prompt. If I do a "New" contact or "edit" I do not get a > >"prompt" in the select. > > I personally cant understand that. > > On Apr 13, 9:47 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Well it is a telecom thing. If you perform maintenance on equipment then > > you need a form explaining what to do and how to do it. > > > > Anyway, the partial gives me a "prompt" if I do a delete or if I remove > the > > contact from the form I also do a replace like on an New contact and it > does > > give me a prompt. If I do a "New" contact or "edit" I do not get a > > "prompt" in the select. all CRUD operations use the same partial to > update > > the select, doing ajax inline with the form. > > > > On Sun, Apr 12, 2009 at 11:26 PM, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > Not able to understand the flow of control. > > > What is mop? Could you explain a bit further? This is interesting.. > > > > > On Apr 12, 3:13 am, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Ok this is weird, I have full CRUD working for my contacts table all > > > > doing ajax inline in my form. the odd one is that my delete funtion > > > > uses the same partial as the one above and when I do the rjs for the > > > > update on the select it DOES give me the "Prompt" to select User. > > > > Delete is the only one that the prompt actually comes back on. Same > > > > partial used on all of the updates to the contact select. > > > > > > On Apr 11, 12:26 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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, p.id ] } > > > > > end > > > > > > > On Sat, Apr 11, 2009 at 11:42 AM, Jaryl Sim < > quantum.crus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > >wrote: > > > > > > > > Hmm, hope you can post up more code, even from your controller as > > > > > > well. > > > > > > > > I think that instead of replacing the entire select tag, you can > > > > > > simply replace its contents. Firstly, give the select tag an id > so > > > > > > that in your RJS, you can replace_html with options_for_select or > > > > > > whatever function you might want to use. > > > > > > > > On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Ok, that select I put is the only thing in the partial. > > > > > > > Here is the rjs: > > > > > > > page[:contact_list].replace_html :partial => > ''updateContactList'', > > > :locals > > > > > > => > > > > > > > { :contact => @contact } > > > > > > > > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > > > > > > Me wrote: > > > > > > > > > I have this select in a form: > > > > > > > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select > > > Contact''} > > > > > > , > > > > > > > > > { :onchange => remote_function(:url => { :controller > => > > > > > > > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, > > > :with => > > > > > > > > > "''contactid='' + this.value" ) > > > > > > > > > } ) %> > > > > > > > > > > > The prompt works in the form but when I do a replace_html > on it > > > I get > > > > > > > > > everything but the prompt. > > > > > > > > > > Post the replace_html code? > > > > > > > > > > Next, put only that <%= select %> thing into a partial (yes > tiny > > > > > > otherwise > > > > > > > > useless partials are a Best Practice), then do > rjs.replace_html > > > > > > :my_div, > > > > > > > > :partial => ''my_partial''. (I call "rjs" the variable everyone > > > else > > > > > > calls > > > > > > > > "page", > > > > > > > > because the interthing has too many "page" variables all over > > > it!) > > > > > > > > > > You could also see about putting the :url into a named route. > > > Just > > > > > > about > > > > > > > > anything in Rails that''s "named" is a best practice, too! > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sure.. lets take this outside! ;) It''ll help if you send me the code with the flow for one action that works and one that doesnt. no promises :). On Apr 13, 10:10 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok, you asked what a mop was. > > ajaxAddtoMop just makes the association between the contact and form then > updates the select removing the user from the select box. I have quite a > few rjs and partials to make the full CRUD operations working ajax wise > inline in the form. I can go offline if you really want to know all of the > files being used, kinda lengthy here. > > The same partial is used between all actions doing a replace :partial. > Just odd that only a couple of the functions give me the prompt. Basically > it is really just a contact to form relationship. I may be using this same > thing down the road I am sure. All of the new,edit,update,deletes of users > are right in the form. Kinda cool really. > > On Mon, Apr 13, 2009 at 12:00 AM, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I meant the flow of control in the code. > > From the view to the controller action, to the RJS and back to the > > view. > > I dont see a call to ajaxAddToMop. > > What are the names of the files with the RJS and the select_box? > > > >if I do a delete or if I remove the > > >contact from the form I also do a replace like on an New contact and it > > does > > >give me a prompt. If I do a "New" contact or "edit" I do not get a > > >"prompt" in the select. > > > I personally cant understand that. > > > On Apr 13, 9:47 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Well it is a telecom thing. If you perform maintenance on equipment then > > > you need a form explaining what to do and how to do it. > > > > Anyway, the partial gives me a "prompt" if I do a delete or if I remove > > the > > > contact from the form I also do a replace like on an New contact and it > > does > > > give me a prompt. If I do a "New" contact or "edit" I do not get a > > > "prompt" in the select. all CRUD operations use the same partial to > > update > > > the select, doing ajax inline with the form. > > > > On Sun, Apr 12, 2009 at 11:26 PM, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > > Not able to understand the flow of control. > > > > What is mop? Could you explain a bit further? This is interesting.. > > > > > On Apr 12, 3:13 am, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Ok this is weird, I have full CRUD working for my contacts table all > > > > > doing ajax inline in my form. the odd one is that my delete funtion > > > > > uses the same partial as the one above and when I do the rjs for the > > > > > update on the select it DOES give me the "Prompt" to select User. > > > > > Delete is the only one that the prompt actually comes back on. Same > > > > > partial used on all of the updates to the contact select. > > > > > > On Apr 11, 12:26 pm, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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, p.id ] } > > > > > > end > > > > > > > On Sat, Apr 11, 2009 at 11:42 AM, Jaryl Sim < > > quantum.crus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > > >wrote: > > > > > > > > Hmm, hope you can post up more code, even from your controller as > > > > > > > well. > > > > > > > > I think that instead of replacing the entire select tag, you can > > > > > > > simply replace its contents. Firstly, give the select tag an id > > so > > > > > > > that in your RJS, you can replace_html with options_for_select or > > > > > > > whatever function you might want to use. > > > > > > > > On Apr 11, 8:01 am, Chris Habgood <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > Ok, that select I put is the only thing in the partial. > > > > > > > > Here is the rjs: > > > > > > > > page[:contact_list].replace_html :partial => > > ''updateContactList'', > > > > :locals > > > > > > > => > > > > > > > > { :contact => @contact } > > > > > > > > > On Fri, Apr 10, 2009 at 6:58 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > wrote: > > > > > > > > > > Me wrote: > > > > > > > > > > I have this select in a form: > > > > > > > > > > <%= select(''contact'', ''id'', @contacts, {:prompt => ''Select > > > > Contact''} > > > > > > > , > > > > > > > > > > { :onchange => remote_function(:url => { :controller > > => > > > > > > > > > > ''contacts'', :action => "ajaxshowcontact", :id => @mop.id}, > > > > :with => > > > > > > > > > > "''contactid='' + this.value" ) > > > > > > > > > > } ) %> > > > > > > > > > > > The prompt works in the form but when I do a replace_html > > on it > > > > I get > > > > > > > > > > everything but the prompt. > > > > > > > > > > Post the replace_html code? > > > > > > > > > > Next, put only that <%= select %> thing into a partial (yes > > tiny > > > > > > > otherwise > > > > > > > > > useless partials are a Best Practice), then do > > rjs.replace_html > > > > > > > :my_div, > > > > > > > > > :partial => ''my_partial''. (I call "rjs" the variable everyone > > > > else > > > > > > > calls > > > > > > > > > "page", > > > > > > > > > because the interthing has too many "page" variables all over > > > > it!) > > > > > > > > > > You could also see about putting the :url into a named route. > > > > Just > > > > > > > about > > > > > > > > > anything in Rails that''s "named" is a best practice, too!--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---