HI , I have a state and country drop down in my client form and i want that state to be populated when a country is selected, How ever iam struggling on it... i dont want to implement plain JavaScript but AJAX for this, please let me know any resources or the rite direction.. Thanks in Advance -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
This is a good resource to start: http://railscasts.com/episodes/88-dynamic-select-menus 2012/5/2 AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> HI , I have a state and country drop down in my client form and i > want that state to be populated when a country is selected, How ever > iam struggling on it... i dont want to implement plain JavaScript but > AJAX for this, please let me know any resources or the rite > direction.. > > Thanks in Advance > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Laura i have gone through this but it has an example where Javascript has been used , i want to use AJAX and JQuery, Thanks On Wed, May 2, 2012 at 7:34 PM, Lauro Caetano <laurocaetano1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> This is a good resource to start: > http://railscasts.com/episodes/88-dynamic-select-menus > > 2012/5/2 AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> HI , I have a state and country drop down in my client form and i >> want that state to be populated when a country is selected, How ever >> iam struggling on it... i dont want to implement plain JavaScript but >> AJAX for this, please let me know any resources or the rite >> direction.. >> >> Thanks in Advance >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i have gone through this but it has an example where Javascript has been > used , i want to use AJAX and JQuery,So what''s the problem? What have you tried so far, and how did it not work? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Hassan, I am Bit of a novoice to this...... iam nt sure wether this is correct approach...in my application.js file i have wriiten $(document).ready(function() { $("#client_country_id").change(function() { $.ajax({ type: "GET", url: ''/states/1'', success: function(data) { // Code } }); }); }); and my clients form has state feidl like this <div class="field row odd"> <%= f.label :state1 %> <%= f.select ''state_id'', State.find(:all).collect{|s| [s.name,s.id]} %> </div> now i want to pass the country id and ftecth state depending on it..... do i include the above div in a prtial and what to write in the state controller..... Thanks in advance. Thanks & Regards, On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar > > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > i have gone through this but it has an example where Javascript has been > > used , i want to use AJAX and JQuery, > > So what''s the problem? What have you tried so far, and how did it > not work? > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe80Tx58lXaADg@public.gmane.org://about.me/hassanschroeder > twitter: @hassan-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Hey AJ In your ajax call, you need to pass the id of the selected state if you are using a nested resource url structure. Your js would looks something like this: $(document).ready(function() { var country_states_path = ''/countries/:id/states; $("#client_country_id").change(function() { var state_id = $(this).val(); $.ajax({ type: "GET", url: country_states_path.replace(":id", id), success: function(data) { // Code to populate cities } }); }); }); Incase you are not using nested resources, you still need to pass the state_id that was selected currently. Using the below js, in your controller, the state id would be available as params[:state] $(document).ready(function() { var country_states_path = ''/states/''; $("#client_country_id").change(function() { var country_id = $(this).val(); $.ajax({ type: "GET", data: {country: country_id}, url: country_states_path, success: function(data) { // Code to populate cities } }); }); }); On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Hassan, > > I am Bit of a novoice to this...... iam nt sure wether this is correct > approach...in my application.js file i have wriiten > > $(document).ready(function() { > $("#client_country_id").change(function() { > $.ajax({ > type: "GET", > url: ''/states/1'', > success: function(data) { > // Code > } > }); > }); > }); > > > and my clients form has state feidl like this > > > <div class="field row odd"> > <%= f.label :state1 %> > <%= f.select ''state_id'', State.find(:all).collect{|s| > [s.name,s.id]} %> > </div> > > > now i want to pass the country id and ftecth state depending on > it..... do i include the above div in a prtial and what to write in > the state controller..... > > Thanks in advance. > > > > Thanks & Regards, > > On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar > > > > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i have gone through this but it has an example where Javascript has > been > > > used , i want to use AJAX and JQuery, > > > > So what''s the problem? What have you tried so far, and how did it > > not work? > > > > -- > > Hassan Schroeder ------------------------ hassan.schroe... > @gmail.comhttp://about.me/hassanschroeder > > twitter: @hassan > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- - Aziz M. Bookwala -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hey Aziz, really thanks for you repl..........so do i need to write a controller action that would return me the states depending on the country and how do i render the state drop down in Cilent Form...Thanks.... Thanks, AJ On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hey AJ > > In your ajax call, you need to pass the id of the selected state if you > are using a nested resource url structure. > Your js would looks something like this: > > $(document).ready(function() { > var country_states_path = ''/countries/:id/states; > $("#client_country_id").change(function() { > var state_id = $(this).val(); > $.ajax({ > type: "GET", > url: country_states_path.replace(":id", id), > success: function(data) { > // Code to populate cities > } > }); > }); > }); > > Incase you are not using nested resources, you still need to pass the > state_id that was selected currently. Using the below js, in your > controller, the state id would be available as params[:state] > > $(document).ready(function() { > var country_states_path = ''/states/''; > $("#client_country_id").change(function() { > var country_id = $(this).val(); > $.ajax({ > type: "GET", > data: {country: country_id}, > url: country_states_path, > success: function(data) { > // Code to populate cities > } > }); > }); > }); > > > > On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi Hassan, >> >> I am Bit of a novoice to this...... iam nt sure wether this is correct >> approach...in my application.js file i have wriiten >> >> $(document).ready(function() { >> $("#client_country_id").change(function() { >> $.ajax({ >> type: "GET", >> url: ''/states/1'', >> success: function(data) { >> // Code >> } >> }); >> }); >> }); >> >> >> and my clients form has state feidl like this >> >> >> <div class="field row odd"> >> <%= f.label :state1 %> >> <%= f.select ''state_id'', State.find(:all).collect{|s| >> [s.name,s.id]} %> >> </div> >> >> >> now i want to pass the country id and ftecth state depending on >> it..... do i include the above div in a prtial and what to write in >> the state controller..... >> >> Thanks in advance. >> >> >> >> Thanks & Regards, >> >> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >> > >> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > > i have gone through this but it has an example where Javascript has >> been >> > > used , i want to use AJAX and JQuery, >> > >> > So what''s the problem? What have you tried so far, and how did it >> > not work? >> > >> > -- >> > Hassan Schroeder ------------------------ hassan.schroe... >> @gmail.comhttp://about.me/hassanschroeder >> > twitter: @hassan >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > -- > - Aziz M. Bookwala > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hey AJ Yes, to serve any request made by your client, you would need something on the server to handle the request. As for rendering the dropdown, this is a pretty simple thing to do with jQuery. Look around, you should find something quite easily. On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Aziz, > > really thanks for you repl..........so do i need to write a > controller action that would return me the states depending on the country > and how do i render the state drop down in Cilent Form...Thanks.... > > Thanks, > AJ > > > On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Hey AJ >> >> In your ajax call, you need to pass the id of the selected state if you >> are using a nested resource url structure. >> Your js would looks something like this: >> >> $(document).ready(function() { >> var country_states_path = ''/countries/:id/states; >> $("#client_country_id").change(function() { >> var state_id = $(this).val(); >> $.ajax({ >> type: "GET", >> url: country_states_path.replace(":id", id), >> success: function(data) { >> // Code to populate cities >> } >> }); >> }); >> }); >> >> Incase you are not using nested resources, you still need to pass the >> state_id that was selected currently. Using the below js, in your >> controller, the state id would be available as params[:state] >> >> $(document).ready(function() { >> var country_states_path = ''/states/''; >> $("#client_country_id").change(function() { >> var country_id = $(this).val(); >> $.ajax({ >> type: "GET", >> data: {country: country_id}, >> url: country_states_path, >> success: function(data) { >> // Code to populate cities >> } >> }); >> }); >> }); >> >> >> >> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Hi Hassan, >>> >>> I am Bit of a novoice to this...... iam nt sure wether this is correct >>> approach...in my application.js file i have wriiten >>> >>> $(document).ready(function() { >>> $("#client_country_id").change(function() { >>> $.ajax({ >>> type: "GET", >>> url: ''/states/1'', >>> success: function(data) { >>> // Code >>> } >>> }); >>> }); >>> }); >>> >>> >>> and my clients form has state feidl like this >>> >>> >>> <div class="field row odd"> >>> <%= f.label :state1 %> >>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>> [s.name,s.id]} %> >>> </div> >>> >>> >>> now i want to pass the country id and ftecth state depending on >>> it..... do i include the above div in a prtial and what to write in >>> the state controller..... >>> >>> Thanks in advance. >>> >>> >>> >>> Thanks & Regards, >>> >>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> wrote: >>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>> > >>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> > > i have gone through this but it has an example where Javascript has >>> been >>> > > used , i want to use AJAX and JQuery, >>> > >>> > So what''s the problem? What have you tried so far, and how did it >>> > not work? >>> > >>> > -- >>> > Hassan Schroeder ------------------------ hassan.schroe... >>> @gmail.comhttp://about.me/hassanschroeder >>> > twitter: @hassan >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >>> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- - Aziz M. Bookwala -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Aziz....... I have wriiten a countries_state action and in states controller, and in application.js i have modified the path like this var country_states_path = ''/states/countries_state/''; however on console its giving me eroor like <pre>Couldn''t find State with id=countries_state</pre> ... Iam struggling to find what;s going wrong as iam pretty new to all this...thanks a lot all of you for your help...... On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hey AJ > > Yes, to serve any request made by your client, you would need something on > the server to handle the request. > As for rendering the dropdown, this is a pretty simple thing to do with > jQuery. Look around, you should find something quite easily. > > > On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hey Aziz, >> >> really thanks for you repl..........so do i need to write a >> controller action that would return me the states depending on the country >> and how do i render the state drop down in Cilent Form...Thanks.... >> >> Thanks, >> AJ >> >> >> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> Hey AJ >>> >>> In your ajax call, you need to pass the id of the selected state if you >>> are using a nested resource url structure. >>> Your js would looks something like this: >>> >>> $(document).ready(function() { >>> var country_states_path = ''/countries/:id/states; >>> $("#client_country_id").change(function() { >>> var state_id = $(this).val(); >>> $.ajax({ >>> type: "GET", >>> url: country_states_path.replace(":id", id), >>> success: function(data) { >>> // Code to populate cities >>> } >>> }); >>> }); >>> }); >>> >>> Incase you are not using nested resources, you still need to pass the >>> state_id that was selected currently. Using the below js, in your >>> controller, the state id would be available as params[:state] >>> >>> $(document).ready(function() { >>> var country_states_path = ''/states/''; >>> $("#client_country_id").change(function() { >>> var country_id = $(this).val(); >>> $.ajax({ >>> type: "GET", >>> data: {country: country_id}, >>> url: country_states_path, >>> success: function(data) { >>> // Code to populate cities >>> } >>> }); >>> }); >>> }); >>> >>> >>> >>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Hi Hassan, >>>> >>>> I am Bit of a novoice to this...... iam nt sure wether this is correct >>>> approach...in my application.js file i have wriiten >>>> >>>> $(document).ready(function() { >>>> $("#client_country_id").change(function() { >>>> $.ajax({ >>>> type: "GET", >>>> url: ''/states/1'', >>>> success: function(data) { >>>> // Code >>>> } >>>> }); >>>> }); >>>> }); >>>> >>>> >>>> and my clients form has state feidl like this >>>> >>>> >>>> <div class="field row odd"> >>>> <%= f.label :state1 %> >>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>> [s.name,s.id]} %> >>>> </div> >>>> >>>> >>>> now i want to pass the country id and ftecth state depending on >>>> it..... do i include the above div in a prtial and what to write in >>>> the state controller..... >>>> >>>> Thanks in advance. >>>> >>>> >>>> >>>> Thanks & Regards, >>>> >>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>> wrote: >>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>> > >>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> > > i have gone through this but it has an example where Javascript has >>>> been >>>> > > used , i want to use AJAX and JQuery, >>>> > >>>> > So what''s the problem? What have you tried so far, and how did it >>>> > not work? >>>> > >>>> > -- >>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>> @gmail.comhttp://about.me/hassanschroeder >>>> > twitter: @hassan >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>>> >>> >>> >>> -- >>> - Aziz M. Bookwala >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > - Aziz M. Bookwala > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Did you add a route for this new action? On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Aziz....... I have wriiten a countries_state action and in states > controller, and in application.js i have modified the path like this > var country_states_path = ''/states/countries_state/''; however on console > its giving me eroor like > <pre>Couldn''t find State with id=countries_state</pre> ... Iam struggling > to find what;s going wrong as iam pretty new to all this...thanks a lot all > of you for your help...... > > > On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Hey AJ >> >> Yes, to serve any request made by your client, you would need something >> on the server to handle the request. >> As for rendering the dropdown, this is a pretty simple thing to do with >> jQuery. Look around, you should find something quite easily. >> >> >> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Hey Aziz, >>> >>> really thanks for you repl..........so do i need to write a >>> controller action that would return me the states depending on the country >>> and how do i render the state drop down in Cilent Form...Thanks.... >>> >>> Thanks, >>> AJ >>> >>> >>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> Hey AJ >>>> >>>> In your ajax call, you need to pass the id of the selected state if you >>>> are using a nested resource url structure. >>>> Your js would looks something like this: >>>> >>>> $(document).ready(function() { >>>> var country_states_path = ''/countries/:id/states; >>>> $("#client_country_id").change(function() { >>>> var state_id = $(this).val(); >>>> $.ajax({ >>>> type: "GET", >>>> url: country_states_path.replace(":id", id), >>>> success: function(data) { >>>> // Code to populate cities >>>> } >>>> }); >>>> }); >>>> }); >>>> >>>> Incase you are not using nested resources, you still need to pass the >>>> state_id that was selected currently. Using the below js, in your >>>> controller, the state id would be available as params[:state] >>>> >>>> $(document).ready(function() { >>>> var country_states_path = ''/states/''; >>>> $("#client_country_id").change(function() { >>>> var country_id = $(this).val(); >>>> $.ajax({ >>>> type: "GET", >>>> data: {country: country_id}, >>>> url: country_states_path, >>>> success: function(data) { >>>> // Code to populate cities >>>> } >>>> }); >>>> }); >>>> }); >>>> >>>> >>>> >>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> Hi Hassan, >>>>> >>>>> I am Bit of a novoice to this...... iam nt sure wether this is correct >>>>> approach...in my application.js file i have wriiten >>>>> >>>>> $(document).ready(function() { >>>>> $("#client_country_id").change(function() { >>>>> $.ajax({ >>>>> type: "GET", >>>>> url: ''/states/1'', >>>>> success: function(data) { >>>>> // Code >>>>> } >>>>> }); >>>>> }); >>>>> }); >>>>> >>>>> >>>>> and my clients form has state feidl like this >>>>> >>>>> >>>>> <div class="field row odd"> >>>>> <%= f.label :state1 %> >>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>> [s.name,s.id]} %> >>>>> </div> >>>>> >>>>> >>>>> now i want to pass the country id and ftecth state depending on >>>>> it..... do i include the above div in a prtial and what to write in >>>>> the state controller..... >>>>> >>>>> Thanks in advance. >>>>> >>>>> >>>>> >>>>> Thanks & Regards, >>>>> >>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>> wrote: >>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>> > >>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> > > i have gone through this but it has an example where Javascript >>>>> has been >>>>> > > used , i want to use AJAX and JQuery, >>>>> > >>>>> > So what''s the problem? What have you tried so far, and how did it >>>>> > not work? >>>>> > >>>>> > -- >>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>> @gmail.comhttp://about.me/hassanschroeder >>>>> > twitter: @hassan >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>>> >>>> >>>> >>>> -- >>>> - Aziz M. Bookwala >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- - Aziz M. Bookwala -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
my country_state action looks like this def countries_state @state = State.find("country_id = :c_id",{:c_id=>params[:country_id]}) respond_to do |format| format.js end end On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Aziz....... I have wriiten a countries_state action and in states > controller, and in application.js i have modified the path like this > var country_states_path = ''/states/countries_state/''; however on console > its giving me eroor like > <pre>Couldn''t find State with id=countries_state</pre> ... Iam struggling > to find what;s going wrong as iam pretty new to all this...thanks a lot all > of you for your help...... > > > On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Hey AJ >> >> Yes, to serve any request made by your client, you would need something >> on the server to handle the request. >> As for rendering the dropdown, this is a pretty simple thing to do with >> jQuery. Look around, you should find something quite easily. >> >> >> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Hey Aziz, >>> >>> really thanks for you repl..........so do i need to write a >>> controller action that would return me the states depending on the country >>> and how do i render the state drop down in Cilent Form...Thanks.... >>> >>> Thanks, >>> AJ >>> >>> >>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> Hey AJ >>>> >>>> In your ajax call, you need to pass the id of the selected state if you >>>> are using a nested resource url structure. >>>> Your js would looks something like this: >>>> >>>> $(document).ready(function() { >>>> var country_states_path = ''/countries/:id/states; >>>> $("#client_country_id").change(function() { >>>> var state_id = $(this).val(); >>>> $.ajax({ >>>> type: "GET", >>>> url: country_states_path.replace(":id", id), >>>> success: function(data) { >>>> // Code to populate cities >>>> } >>>> }); >>>> }); >>>> }); >>>> >>>> Incase you are not using nested resources, you still need to pass the >>>> state_id that was selected currently. Using the below js, in your >>>> controller, the state id would be available as params[:state] >>>> >>>> $(document).ready(function() { >>>> var country_states_path = ''/states/''; >>>> $("#client_country_id").change(function() { >>>> var country_id = $(this).val(); >>>> $.ajax({ >>>> type: "GET", >>>> data: {country: country_id}, >>>> url: country_states_path, >>>> success: function(data) { >>>> // Code to populate cities >>>> } >>>> }); >>>> }); >>>> }); >>>> >>>> >>>> >>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> Hi Hassan, >>>>> >>>>> I am Bit of a novoice to this...... iam nt sure wether this is correct >>>>> approach...in my application.js file i have wriiten >>>>> >>>>> $(document).ready(function() { >>>>> $("#client_country_id").change(function() { >>>>> $.ajax({ >>>>> type: "GET", >>>>> url: ''/states/1'', >>>>> success: function(data) { >>>>> // Code >>>>> } >>>>> }); >>>>> }); >>>>> }); >>>>> >>>>> >>>>> and my clients form has state feidl like this >>>>> >>>>> >>>>> <div class="field row odd"> >>>>> <%= f.label :state1 %> >>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>> [s.name,s.id]} %> >>>>> </div> >>>>> >>>>> >>>>> now i want to pass the country id and ftecth state depending on >>>>> it..... do i include the above div in a prtial and what to write in >>>>> the state controller..... >>>>> >>>>> Thanks in advance. >>>>> >>>>> >>>>> >>>>> Thanks & Regards, >>>>> >>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>> wrote: >>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>> > >>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> > > i have gone through this but it has an example where Javascript >>>>> has been >>>>> > > used , i want to use AJAX and JQuery, >>>>> > >>>>> > So what''s the problem? What have you tried so far, and how did it >>>>> > not work? >>>>> > >>>>> > -- >>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>> @gmail.comhttp://about.me/hassanschroeder >>>>> > twitter: @hassan >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>>> >>>> >>>> >>>> -- >>>> - Aziz M. Bookwala >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes i have added....it looks like this match "/states/countries_state/:country_id" => "states#countries_state" On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Did you add a route for this new action? > > > On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Thanks Aziz....... I have wriiten a countries_state action and in states >> controller, and in application.js i have modified the path like this >> var country_states_path = ''/states/countries_state/''; however on console >> its giving me eroor like >> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >> struggling to find what;s going wrong as iam pretty new to all >> this...thanks a lot all of you for your help...... >> >> >> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> Hey AJ >>> >>> Yes, to serve any request made by your client, you would need something >>> on the server to handle the request. >>> As for rendering the dropdown, this is a pretty simple thing to do with >>> jQuery. Look around, you should find something quite easily. >>> >>> >>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Hey Aziz, >>>> >>>> really thanks for you repl..........so do i need to write a >>>> controller action that would return me the states depending on the country >>>> and how do i render the state drop down in Cilent Form...Thanks.... >>>> >>>> Thanks, >>>> AJ >>>> >>>> >>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> Hey AJ >>>>> >>>>> In your ajax call, you need to pass the id of the selected state if >>>>> you are using a nested resource url structure. >>>>> Your js would looks something like this: >>>>> >>>>> $(document).ready(function() { >>>>> var country_states_path = ''/countries/:id/states; >>>>> $("#client_country_id").change(function() { >>>>> var state_id = $(this).val(); >>>>> $.ajax({ >>>>> type: "GET", >>>>> url: country_states_path.replace(":id", id), >>>>> success: function(data) { >>>>> // Code to populate cities >>>>> } >>>>> }); >>>>> }); >>>>> }); >>>>> >>>>> Incase you are not using nested resources, you still need to pass the >>>>> state_id that was selected currently. Using the below js, in your >>>>> controller, the state id would be available as params[:state] >>>>> >>>>> $(document).ready(function() { >>>>> var country_states_path = ''/states/''; >>>>> $("#client_country_id").change(function() { >>>>> var country_id = $(this).val(); >>>>> $.ajax({ >>>>> type: "GET", >>>>> data: {country: country_id}, >>>>> url: country_states_path, >>>>> success: function(data) { >>>>> // Code to populate cities >>>>> } >>>>> }); >>>>> }); >>>>> }); >>>>> >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>> >>>>>> Hi Hassan, >>>>>> >>>>>> I am Bit of a novoice to this...... iam nt sure wether this is correct >>>>>> approach...in my application.js file i have wriiten >>>>>> >>>>>> $(document).ready(function() { >>>>>> $("#client_country_id").change(function() { >>>>>> $.ajax({ >>>>>> type: "GET", >>>>>> url: ''/states/1'', >>>>>> success: function(data) { >>>>>> // Code >>>>>> } >>>>>> }); >>>>>> }); >>>>>> }); >>>>>> >>>>>> >>>>>> and my clients form has state feidl like this >>>>>> >>>>>> >>>>>> <div class="field row odd"> >>>>>> <%= f.label :state1 %> >>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>> [s.name,s.id]} %> >>>>>> </div> >>>>>> >>>>>> >>>>>> now i want to pass the country id and ftecth state depending on >>>>>> it..... do i include the above div in a prtial and what to write in >>>>>> the state controller..... >>>>>> >>>>>> Thanks in advance. >>>>>> >>>>>> >>>>>> >>>>>> Thanks & Regards, >>>>>> >>>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>> wrote: >>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>> > >>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> > > i have gone through this but it has an example where Javascript >>>>>> has been >>>>>> > > used , i want to use AJAX and JQuery, >>>>>> > >>>>>> > So what''s the problem? What have you tried so far, and how did it >>>>>> > not work? >>>>>> > >>>>>> > -- >>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>> > twitter: @hassan >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> - Aziz M. Bookwala >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> - Aziz M. Bookwala >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > - Aziz M. Bookwala > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Make sure this route comes before the route entry for the country resource. On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes i have added....it looks like this > > match "/states/countries_state/:country_id" => "states#countries_state" > > > On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Did you add a route for this new action? >> >> >> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Thanks Aziz....... I have wriiten a countries_state action and in states >>> controller, and in application.js i have modified the path like this >>> var country_states_path = ''/states/countries_state/''; however on console >>> its giving me eroor like >>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>> struggling to find what;s going wrong as iam pretty new to all >>> this...thanks a lot all of you for your help...... >>> >>> >>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> Hey AJ >>>> >>>> Yes, to serve any request made by your client, you would need something >>>> on the server to handle the request. >>>> As for rendering the dropdown, this is a pretty simple thing to do with >>>> jQuery. Look around, you should find something quite easily. >>>> >>>> >>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> Hey Aziz, >>>>> >>>>> really thanks for you repl..........so do i need to write a >>>>> controller action that would return me the states depending on the country >>>>> and how do i render the state drop down in Cilent Form...Thanks.... >>>>> >>>>> Thanks, >>>>> AJ >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>>> > wrote: >>>>> >>>>>> Hey AJ >>>>>> >>>>>> In your ajax call, you need to pass the id of the selected state if >>>>>> you are using a nested resource url structure. >>>>>> Your js would looks something like this: >>>>>> >>>>>> $(document).ready(function() { >>>>>> var country_states_path = ''/countries/:id/states; >>>>>> $("#client_country_id").change(function() { >>>>>> var state_id = $(this).val(); >>>>>> $.ajax({ >>>>>> type: "GET", >>>>>> url: country_states_path.replace(":id", id), >>>>>> success: function(data) { >>>>>> // Code to populate cities >>>>>> } >>>>>> }); >>>>>> }); >>>>>> }); >>>>>> >>>>>> Incase you are not using nested resources, you still need to pass the >>>>>> state_id that was selected currently. Using the below js, in your >>>>>> controller, the state id would be available as params[:state] >>>>>> >>>>>> $(document).ready(function() { >>>>>> var country_states_path = ''/states/''; >>>>>> $("#client_country_id").change(function() { >>>>>> var country_id = $(this).val(); >>>>>> $.ajax({ >>>>>> type: "GET", >>>>>> data: {country: country_id}, >>>>>> url: country_states_path, >>>>>> success: function(data) { >>>>>> // Code to populate cities >>>>>> } >>>>>> }); >>>>>> }); >>>>>> }); >>>>>> >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>>> >>>>>>> Hi Hassan, >>>>>>> >>>>>>> I am Bit of a novoice to this...... iam nt sure wether this is >>>>>>> correct >>>>>>> approach...in my application.js file i have wriiten >>>>>>> >>>>>>> $(document).ready(function() { >>>>>>> $("#client_country_id").change(function() { >>>>>>> $.ajax({ >>>>>>> type: "GET", >>>>>>> url: ''/states/1'', >>>>>>> success: function(data) { >>>>>>> // Code >>>>>>> } >>>>>>> }); >>>>>>> }); >>>>>>> }); >>>>>>> >>>>>>> >>>>>>> and my clients form has state feidl like this >>>>>>> >>>>>>> >>>>>>> <div class="field row odd"> >>>>>>> <%= f.label :state1 %> >>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>> [s.name,s.id]} %> >>>>>>> </div> >>>>>>> >>>>>>> >>>>>>> now i want to pass the country id and ftecth state depending on >>>>>>> it..... do i include the above div in a prtial and what to write in >>>>>>> the state controller..... >>>>>>> >>>>>>> Thanks in advance. >>>>>>> >>>>>>> >>>>>>> >>>>>>> Thanks & Regards, >>>>>>> >>>>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>> wrote: >>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>> > >>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> > > i have gone through this but it has an example where Javascript >>>>>>> has been >>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>> > >>>>>>> > So what''s the problem? What have you tried so far, and how did it >>>>>>> > not work? >>>>>>> > >>>>>>> > -- >>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>> > twitter: @hassan >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> - Aziz M. Bookwala >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks & Regards, >>>>> Akshar Jamgaonkar >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> - Aziz M. Bookwala >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- - Aziz M. Bookwala -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yea it looks like this... match "/states/countries_state/:country_id" => "states#countries_state" resources :clients resources :skill_sets resources :technologies resources :level_of_contacts resources :states resources :discounts resources :countries resources :roles get "home/index" On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Make sure this route comes before the route entry for the country resource. > > > On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Yes i have added....it looks like this >> >> match "/states/countries_state/:country_id" => "states#countries_state" >> >> >> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> Did you add a route for this new action? >>> >>> >>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Thanks Aziz....... I have wriiten a countries_state action and in >>>> states controller, and in application.js i have modified the path like this >>>> var country_states_path = ''/states/countries_state/''; however on >>>> console its giving me eroor like >>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>> struggling to find what;s going wrong as iam pretty new to all >>>> this...thanks a lot all of you for your help...... >>>> >>>> >>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> Hey AJ >>>>> >>>>> Yes, to serve any request made by your client, you would need >>>>> something on the server to handle the request. >>>>> As for rendering the dropdown, this is a pretty simple thing to do >>>>> with jQuery. Look around, you should find something quite easily. >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> Hey Aziz, >>>>>> >>>>>> really thanks for you repl..........so do i need to write a >>>>>> controller action that would return me the states depending on the country >>>>>> and how do i render the state drop down in Cilent Form...Thanks.... >>>>>> >>>>>> Thanks, >>>>>> AJ >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Hey AJ >>>>>>> >>>>>>> In your ajax call, you need to pass the id of the selected state if >>>>>>> you are using a nested resource url structure. >>>>>>> Your js would looks something like this: >>>>>>> >>>>>>> $(document).ready(function() { >>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>> $("#client_country_id").change(function() { >>>>>>> var state_id = $(this).val(); >>>>>>> $.ajax({ >>>>>>> type: "GET", >>>>>>> url: country_states_path.replace(":id", id), >>>>>>> success: function(data) { >>>>>>> // Code to populate cities >>>>>>> } >>>>>>> }); >>>>>>> }); >>>>>>> }); >>>>>>> >>>>>>> Incase you are not using nested resources, you still need to pass >>>>>>> the state_id that was selected currently. Using the below js, in your >>>>>>> controller, the state id would be available as params[:state] >>>>>>> >>>>>>> $(document).ready(function() { >>>>>>> var country_states_path = ''/states/''; >>>>>>> $("#client_country_id").change(function() { >>>>>>> var country_id = $(this).val(); >>>>>>> $.ajax({ >>>>>>> type: "GET", >>>>>>> data: {country: country_id}, >>>>>>> url: country_states_path, >>>>>>> success: function(data) { >>>>>>> // Code to populate cities >>>>>>> } >>>>>>> }); >>>>>>> }); >>>>>>> }); >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>>>> >>>>>>>> Hi Hassan, >>>>>>>> >>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this is >>>>>>>> correct >>>>>>>> approach...in my application.js file i have wriiten >>>>>>>> >>>>>>>> $(document).ready(function() { >>>>>>>> $("#client_country_id").change(function() { >>>>>>>> $.ajax({ >>>>>>>> type: "GET", >>>>>>>> url: ''/states/1'', >>>>>>>> success: function(data) { >>>>>>>> // Code >>>>>>>> } >>>>>>>> }); >>>>>>>> }); >>>>>>>> }); >>>>>>>> >>>>>>>> >>>>>>>> and my clients form has state feidl like this >>>>>>>> >>>>>>>> >>>>>>>> <div class="field row odd"> >>>>>>>> <%= f.label :state1 %> >>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>> [s.name,s.id]} %> >>>>>>>> </div> >>>>>>>> >>>>>>>> >>>>>>>> now i want to pass the country id and ftecth state depending on >>>>>>>> it..... do i include the above div in a prtial and what to write in >>>>>>>> the state controller..... >>>>>>>> >>>>>>>> Thanks in advance. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Thanks & Regards, >>>>>>>> >>>>>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>> wrote: >>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>> > >>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> > > i have gone through this but it has an example where Javascript >>>>>>>> has been >>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>> > >>>>>>>> > So what''s the problem? What have you tried so far, and how did it >>>>>>>> > not work? >>>>>>>> > >>>>>>>> > -- >>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>> > twitter: @hassan >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> - Aziz M. Bookwala >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Thanks & Regards, >>>>>> Akshar Jamgaonkar >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> - Aziz M. Bookwala >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> - Aziz M. Bookwala >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > - Aziz M. Bookwala > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Make sure ur using the currect URL for the new action. On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yea it looks like this... > > > match "/states/countries_state/:country_id" => "states#countries_state" > > resources :clients > > resources :skill_sets > > resources :technologies > > resources :level_of_contacts > > resources :states > > resources :discounts > > resources :countries > > resources :roles > > get "home/index" > > > On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Make sure this route comes before the route entry for the country >> resource. >> >> >> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Yes i have added....it looks like this >>> >>> match "/states/countries_state/:country_id" => "states#countries_state" >>> >>> >>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> Did you add a route for this new action? >>>> >>>> >>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> Thanks Aziz....... I have wriiten a countries_state action and in >>>>> states controller, and in application.js i have modified the path like this >>>>> var country_states_path = ''/states/countries_state/''; however on >>>>> console its giving me eroor like >>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>> struggling to find what;s going wrong as iam pretty new to all >>>>> this...thanks a lot all of you for your help...... >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>>> > wrote: >>>>> >>>>>> Hey AJ >>>>>> >>>>>> Yes, to serve any request made by your client, you would need >>>>>> something on the server to handle the request. >>>>>> As for rendering the dropdown, this is a pretty simple thing to do >>>>>> with jQuery. Look around, you should find something quite easily. >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Hey Aziz, >>>>>>> >>>>>>> really thanks for you repl..........so do i need to write a >>>>>>> controller action that would return me the states depending on the country >>>>>>> and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>> >>>>>>> Thanks, >>>>>>> AJ >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Hey AJ >>>>>>>> >>>>>>>> In your ajax call, you need to pass the id of the selected state if >>>>>>>> you are using a nested resource url structure. >>>>>>>> Your js would looks something like this: >>>>>>>> >>>>>>>> $(document).ready(function() { >>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>> $("#client_country_id").change(function() { >>>>>>>> var state_id = $(this).val(); >>>>>>>> $.ajax({ >>>>>>>> type: "GET", >>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>> success: function(data) { >>>>>>>> // Code to populate cities >>>>>>>> } >>>>>>>> }); >>>>>>>> }); >>>>>>>> }); >>>>>>>> >>>>>>>> Incase you are not using nested resources, you still need to pass >>>>>>>> the state_id that was selected currently. Using the below js, in your >>>>>>>> controller, the state id would be available as params[:state] >>>>>>>> >>>>>>>> $(document).ready(function() { >>>>>>>> var country_states_path = ''/states/''; >>>>>>>> $("#client_country_id").change(function() { >>>>>>>> var country_id = $(this).val(); >>>>>>>> $.ajax({ >>>>>>>> type: "GET", >>>>>>>> data: {country: country_id}, >>>>>>>> url: country_states_path, >>>>>>>> success: function(data) { >>>>>>>> // Code to populate cities >>>>>>>> } >>>>>>>> }); >>>>>>>> }); >>>>>>>> }); >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>>>>> >>>>>>>>> Hi Hassan, >>>>>>>>> >>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this is >>>>>>>>> correct >>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>> >>>>>>>>> $(document).ready(function() { >>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>> $.ajax({ >>>>>>>>> type: "GET", >>>>>>>>> url: ''/states/1'', >>>>>>>>> success: function(data) { >>>>>>>>> // Code >>>>>>>>> } >>>>>>>>> }); >>>>>>>>> }); >>>>>>>>> }); >>>>>>>>> >>>>>>>>> >>>>>>>>> and my clients form has state feidl like this >>>>>>>>> >>>>>>>>> >>>>>>>>> <div class="field row odd"> >>>>>>>>> <%= f.label :state1 %> >>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>> [s.name,s.id]} %> >>>>>>>>> </div> >>>>>>>>> >>>>>>>>> >>>>>>>>> now i want to pass the country id and ftecth state depending on >>>>>>>>> it..... do i include the above div in a prtial and what to write in >>>>>>>>> the state controller..... >>>>>>>>> >>>>>>>>> Thanks in advance. >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Thanks & Regards, >>>>>>>>> >>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>>> wrote: >>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>> > >>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>> Javascript has been >>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>> > >>>>>>>>> > So what''s the problem? What have you tried so far, and how did it >>>>>>>>> > not work? >>>>>>>>> > >>>>>>>>> > -- >>>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>>> > twitter: @hassan >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> - Aziz M. Bookwala >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Thanks & Regards, >>>>>>> Akshar Jamgaonkar >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> - Aziz M. Bookwala >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks & Regards, >>>>> Akshar Jamgaonkar >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> - Aziz M. Bookwala >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- - Aziz M. Bookwala -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Iam sorry i didnt get you.......... i have created a new action for the ajax stuff is this approach wrong..... This is how my states controller is ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class StatesController < ApplicationController # GET /states # GET /states.json def index @states = State.all respond_to do |format| format.html # index.html.erb format.json { render json: @states } end end # GET /states/1 # GET /states/1.json def show @state = State.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @state } end end # GET /states/new # GET /states/new.json def new @state = State.new respond_to do |format| format.html # new.html.erb format.json { render json: @state } end end # GET /states/1/edit def edit @state = State.find(params[:id]) end # POST /states # POST /states.json def create @state = State.new(params[:state]) respond_to do |format| if @state.save format.html { redirect_to @state, notice: ''State was successfully created.'' } format.json { render json: @state, status: :created, location: @state } else format.html { render action: "new" } format.json { render json: @state.errors, status: :unprocessable_entity } end end end def countries_state @state = State.find("country_id = :c_id",{:c_id => params[:country]}) respond_to do |format| format.html format.js end end # PUT /states/1 # PUT /states/1.json def update @state = State.find(params[:id]) respond_to do |format| if @state.update_attributes(params[:state]) format.html { redirect_to @state, notice: ''State was successfully updated.'' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @state.errors, status: :unprocessable_entity } end end end # DELETE /states/1 # DELETE /states/1.json def destroy @state = State.find(params[:id]) @state.destroy respond_to do |format| format.html { redirect_to states_url } format.json { head :ok } end end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Make sure ur using the currect URL for the new action. > > > On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Yea it looks like this... >> >> >> match "/states/countries_state/:country_id" => "states#countries_state" >> >> resources :clients >> >> resources :skill_sets >> >> resources :technologies >> >> resources :level_of_contacts >> >> resources :states >> >> resources :discounts >> >> resources :countries >> >> resources :roles >> >> get "home/index" >> >> >> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> Make sure this route comes before the route entry for the country >>> resource. >>> >>> >>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Yes i have added....it looks like this >>>> >>>> match "/states/countries_state/:country_id" => "states#countries_state" >>>> >>>> >>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> Did you add a route for this new action? >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> Thanks Aziz....... I have wriiten a countries_state action and in >>>>>> states controller, and in application.js i have modified the path like this >>>>>> var country_states_path = ''/states/countries_state/''; however on >>>>>> console its giving me eroor like >>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>> this...thanks a lot all of you for your help...... >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Hey AJ >>>>>>> >>>>>>> Yes, to serve any request made by your client, you would need >>>>>>> something on the server to handle the request. >>>>>>> As for rendering the dropdown, this is a pretty simple thing to do >>>>>>> with jQuery. Look around, you should find something quite easily. >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Hey Aziz, >>>>>>>> >>>>>>>> really thanks for you repl..........so do i need to write a >>>>>>>> controller action that would return me the states depending on the country >>>>>>>> and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>>> >>>>>>>> Thanks, >>>>>>>> AJ >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Hey AJ >>>>>>>>> >>>>>>>>> In your ajax call, you need to pass the id of the selected state >>>>>>>>> if you are using a nested resource url structure. >>>>>>>>> Your js would looks something like this: >>>>>>>>> >>>>>>>>> $(document).ready(function() { >>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>> var state_id = $(this).val(); >>>>>>>>> $.ajax({ >>>>>>>>> type: "GET", >>>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>>> success: function(data) { >>>>>>>>> // Code to populate cities >>>>>>>>> } >>>>>>>>> }); >>>>>>>>> }); >>>>>>>>> }); >>>>>>>>> >>>>>>>>> Incase you are not using nested resources, you still need to pass >>>>>>>>> the state_id that was selected currently. Using the below js, in your >>>>>>>>> controller, the state id would be available as params[:state] >>>>>>>>> >>>>>>>>> $(document).ready(function() { >>>>>>>>> var country_states_path = ''/states/''; >>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>> var country_id = $(this).val(); >>>>>>>>> $.ajax({ >>>>>>>>> type: "GET", >>>>>>>>> data: {country: country_id}, >>>>>>>>> url: country_states_path, >>>>>>>>> success: function(data) { >>>>>>>>> // Code to populate cities >>>>>>>>> } >>>>>>>>> }); >>>>>>>>> }); >>>>>>>>> }); >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>>>>>> >>>>>>>>>> Hi Hassan, >>>>>>>>>> >>>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this is >>>>>>>>>> correct >>>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>>> >>>>>>>>>> $(document).ready(function() { >>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>> $.ajax({ >>>>>>>>>> type: "GET", >>>>>>>>>> url: ''/states/1'', >>>>>>>>>> success: function(data) { >>>>>>>>>> // Code >>>>>>>>>> } >>>>>>>>>> }); >>>>>>>>>> }); >>>>>>>>>> }); >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> and my clients form has state feidl like this >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> <div class="field row odd"> >>>>>>>>>> <%= f.label :state1 %> >>>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>>> [s.name,s.id]} %> >>>>>>>>>> </div> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> now i want to pass the country id and ftecth state depending on >>>>>>>>>> it..... do i include the above div in a prtial and what to write >>>>>>>>>> in >>>>>>>>>> the state controller..... >>>>>>>>>> >>>>>>>>>> Thanks in advance. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks & Regards, >>>>>>>>>> >>>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>>>> wrote: >>>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>>> > >>>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>>> Javascript has been >>>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>>> > >>>>>>>>>> > So what''s the problem? What have you tried so far, and how did >>>>>>>>>> it >>>>>>>>>> > not work? >>>>>>>>>> > >>>>>>>>>> > -- >>>>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>>>> > twitter: @hassan >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> - Aziz M. Bookwala >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Thanks & Regards, >>>>>>>> Akshar Jamgaonkar >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> - Aziz M. Bookwala >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Thanks & Regards, >>>>>> Akshar Jamgaonkar >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> - Aziz M. Bookwala >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> - Aziz M. Bookwala >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > - Aziz M. Bookwala > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That is fine, though you could make it more ''RESTful'' by adding it as a nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. The RailsCast is a little old, but you should get the idea. With respect to your current problem, what is the url you are using in your js? On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Iam sorry i didnt get you.......... i have created a new action for the > ajax stuff is this approach wrong..... This is how my states controller is > > > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > class StatesController < ApplicationController > # GET /states > # GET /states.json > def index > @states = State.all > > respond_to do |format| > format.html # index.html.erb > format.json { render json: @states } > end > end > > # GET /states/1 > # GET /states/1.json > def show > @state = State.find(params[:id]) > > respond_to do |format| > format.html # show.html.erb > format.json { render json: @state } > end > end > > # GET /states/new > # GET /states/new.json > def new > @state = State.new > respond_to do |format| > format.html # new.html.erb > format.json { render json: @state } > end > end > > # GET /states/1/edit > def edit > @state = State.find(params[:id]) > end > > # POST /states > # POST /states.json > def create > @state = State.new(params[:state]) > > respond_to do |format| > if @state.save > format.html { redirect_to @state, notice: ''State was successfully > created.'' } > format.json { render json: @state, status: :created, location: > @state } > else > format.html { render action: "new" } > format.json { render json: @state.errors, status: > :unprocessable_entity } > end > end > end > > def countries_state > @state = State.find("country_id = :c_id",{:c_id => params[:country]}) > respond_to do |format| > format.html > format.js > end > end > > # PUT /states/1 > # PUT /states/1.json > def update > @state = State.find(params[:id]) > > respond_to do |format| > if @state.update_attributes(params[:state]) > format.html { redirect_to @state, notice: ''State was successfully > updated.'' } > format.json { head :ok } > else > format.html { render action: "edit" } > format.json { render json: @state.errors, status: > :unprocessable_entity } > end > end > end > > # DELETE /states/1 > # DELETE /states/1.json > def destroy > @state = State.find(params[:id]) > @state.destroy > > respond_to do |format| > format.html { redirect_to states_url } > format.json { head :ok } > end > end > end > > > > > > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > > > > > > > > On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Make sure ur using the currect URL for the new action. >> >> >> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Yea it looks like this... >>> >>> >>> match "/states/countries_state/:country_id" => "states#countries_state" >>> >>> resources :clients >>> >>> resources :skill_sets >>> >>> resources :technologies >>> >>> resources :level_of_contacts >>> >>> resources :states >>> >>> resources :discounts >>> >>> resources :countries >>> >>> resources :roles >>> >>> get "home/index" >>> >>> >>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> Make sure this route comes before the route entry for the country >>>> resource. >>>> >>>> >>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> Yes i have added....it looks like this >>>>> >>>>> match "/states/countries_state/:country_id" => "states#countries_state" >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>>> > wrote: >>>>> >>>>>> Did you add a route for this new action? >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Thanks Aziz....... I have wriiten a countries_state action and in >>>>>>> states controller, and in application.js i have modified the path like this >>>>>>> var country_states_path = ''/states/countries_state/''; however on >>>>>>> console its giving me eroor like >>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>>> this...thanks a lot all of you for your help...... >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Hey AJ >>>>>>>> >>>>>>>> Yes, to serve any request made by your client, you would need >>>>>>>> something on the server to handle the request. >>>>>>>> As for rendering the dropdown, this is a pretty simple thing to do >>>>>>>> with jQuery. Look around, you should find something quite easily. >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Hey Aziz, >>>>>>>>> >>>>>>>>> really thanks for you repl..........so do i need to write a >>>>>>>>> controller action that would return me the states depending on the country >>>>>>>>> and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> AJ >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>> >>>>>>>>>> Hey AJ >>>>>>>>>> >>>>>>>>>> In your ajax call, you need to pass the id of the selected state >>>>>>>>>> if you are using a nested resource url structure. >>>>>>>>>> Your js would looks something like this: >>>>>>>>>> >>>>>>>>>> $(document).ready(function() { >>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>> var state_id = $(this).val(); >>>>>>>>>> $.ajax({ >>>>>>>>>> type: "GET", >>>>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>>>> success: function(data) { >>>>>>>>>> // Code to populate cities >>>>>>>>>> } >>>>>>>>>> }); >>>>>>>>>> }); >>>>>>>>>> }); >>>>>>>>>> >>>>>>>>>> Incase you are not using nested resources, you still need to pass >>>>>>>>>> the state_id that was selected currently. Using the below js, in your >>>>>>>>>> controller, the state id would be available as params[:state] >>>>>>>>>> >>>>>>>>>> $(document).ready(function() { >>>>>>>>>> var country_states_path = ''/states/''; >>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>> var country_id = $(this).val(); >>>>>>>>>> $.ajax({ >>>>>>>>>> type: "GET", >>>>>>>>>> data: {country: country_id}, >>>>>>>>>> url: country_states_path, >>>>>>>>>> success: function(data) { >>>>>>>>>> // Code to populate cities >>>>>>>>>> } >>>>>>>>>> }); >>>>>>>>>> }); >>>>>>>>>> }); >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>>>>>>> >>>>>>>>>>> Hi Hassan, >>>>>>>>>>> >>>>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this is >>>>>>>>>>> correct >>>>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>>>> >>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>> $.ajax({ >>>>>>>>>>> type: "GET", >>>>>>>>>>> url: ''/states/1'', >>>>>>>>>>> success: function(data) { >>>>>>>>>>> // Code >>>>>>>>>>> } >>>>>>>>>>> }); >>>>>>>>>>> }); >>>>>>>>>>> }); >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> and my clients form has state feidl like this >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> <div class="field row odd"> >>>>>>>>>>> <%= f.label :state1 %> >>>>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>>>> [s.name,s.id]} %> >>>>>>>>>>> </div> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> now i want to pass the country id and ftecth state depending on >>>>>>>>>>> it..... do i include the above div in a prtial and what to write >>>>>>>>>>> in >>>>>>>>>>> the state controller..... >>>>>>>>>>> >>>>>>>>>>> Thanks in advance. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thanks & Regards, >>>>>>>>>>> >>>>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>>>>> wrote: >>>>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>>>> > >>>>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>>>> Javascript has been >>>>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>>>> > >>>>>>>>>>> > So what''s the problem? What have you tried so far, and how did >>>>>>>>>>> it >>>>>>>>>>> > not work? >>>>>>>>>>> > >>>>>>>>>>> > -- >>>>>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>>>>> > twitter: @hassan >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Thanks & Regards, >>>>>>>>> Akshar Jamgaonkar >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> - Aziz M. Bookwala >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Thanks & Regards, >>>>>>> Akshar Jamgaonkar >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> - Aziz M. Bookwala >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks & Regards, >>>>> Akshar Jamgaonkar >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> - Aziz M. Bookwala >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- - Aziz M. Bookwala -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Aziz ....thanks a lot...really appriaciate your help On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> That is fine, though you could make it more ''RESTful'' by adding it as a > nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. > The RailsCast is a little old, but you should get the idea. > > With respect to your current problem, what is the url you are using in > your js? > > > On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Iam sorry i didnt get you.......... i have created a new action for the >> ajax stuff is this approach wrong..... This is how my states controller is >> >> >> >> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> >> class StatesController < ApplicationController >> # GET /states >> # GET /states.json >> def index >> @states = State.all >> >> respond_to do |format| >> format.html # index.html.erb >> format.json { render json: @states } >> end >> end >> >> # GET /states/1 >> # GET /states/1.json >> def show >> @state = State.find(params[:id]) >> >> respond_to do |format| >> format.html # show.html.erb >> format.json { render json: @state } >> end >> end >> >> # GET /states/new >> # GET /states/new.json >> def new >> @state = State.new >> respond_to do |format| >> format.html # new.html.erb >> format.json { render json: @state } >> end >> end >> >> # GET /states/1/edit >> def edit >> @state = State.find(params[:id]) >> end >> >> # POST /states >> # POST /states.json >> def create >> @state = State.new(params[:state]) >> >> respond_to do |format| >> if @state.save >> format.html { redirect_to @state, notice: ''State was successfully >> created.'' } >> format.json { render json: @state, status: :created, location: >> @state } >> else >> format.html { render action: "new" } >> format.json { render json: @state.errors, status: >> :unprocessable_entity } >> end >> end >> end >> >> def countries_state >> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) >> respond_to do |format| >> format.html >> format.js >> end >> end >> >> # PUT /states/1 >> # PUT /states/1.json >> def update >> @state = State.find(params[:id]) >> >> respond_to do |format| >> if @state.update_attributes(params[:state]) >> format.html { redirect_to @state, notice: ''State was successfully >> updated.'' } >> format.json { head :ok } >> else >> format.html { render action: "edit" } >> format.json { render json: @state.errors, status: >> :unprocessable_entity } >> end >> end >> end >> >> # DELETE /states/1 >> # DELETE /states/1.json >> def destroy >> @state = State.find(params[:id]) >> @state.destroy >> >> respond_to do |format| >> format.html { redirect_to states_url } >> format.json { head :ok } >> end >> end >> end >> >> >> >> >> >> >> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ >> >> >> >> >> >> >> >> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> Make sure ur using the currect URL for the new action. >>> >>> >>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Yea it looks like this... >>>> >>>> >>>> match "/states/countries_state/:country_id" => "states#countries_state" >>>> >>>> resources :clients >>>> >>>> resources :skill_sets >>>> >>>> resources :technologies >>>> >>>> resources :level_of_contacts >>>> >>>> resources :states >>>> >>>> resources :discounts >>>> >>>> resources :countries >>>> >>>> resources :roles >>>> >>>> get "home/index" >>>> >>>> >>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> Make sure this route comes before the route entry for the country >>>>> resource. >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> Yes i have added....it looks like this >>>>>> >>>>>> match "/states/countries_state/:country_id" => >>>>>> "states#countries_state" >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Did you add a route for this new action? >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and in >>>>>>>> states controller, and in application.js i have modified the path like this >>>>>>>> var country_states_path = ''/states/countries_state/''; however on >>>>>>>> console its giving me eroor like >>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>>>> this...thanks a lot all of you for your help...... >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Hey AJ >>>>>>>>> >>>>>>>>> Yes, to serve any request made by your client, you would need >>>>>>>>> something on the server to handle the request. >>>>>>>>> As for rendering the dropdown, this is a pretty simple thing to do >>>>>>>>> with jQuery. Look around, you should find something quite easily. >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>> >>>>>>>>>> Hey Aziz, >>>>>>>>>> >>>>>>>>>> really thanks for you repl..........so do i need to write >>>>>>>>>> a controller action that would return me the states depending on the >>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> AJ >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>> >>>>>>>>>>> Hey AJ >>>>>>>>>>> >>>>>>>>>>> In your ajax call, you need to pass the id of the selected state >>>>>>>>>>> if you are using a nested resource url structure. >>>>>>>>>>> Your js would looks something like this: >>>>>>>>>>> >>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>> var state_id = $(this).val(); >>>>>>>>>>> $.ajax({ >>>>>>>>>>> type: "GET", >>>>>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>>>>> success: function(data) { >>>>>>>>>>> // Code to populate cities >>>>>>>>>>> } >>>>>>>>>>> }); >>>>>>>>>>> }); >>>>>>>>>>> }); >>>>>>>>>>> >>>>>>>>>>> Incase you are not using nested resources, you still need to >>>>>>>>>>> pass the state_id that was selected currently. Using the below js, in your >>>>>>>>>>> controller, the state id would be available as params[:state] >>>>>>>>>>> >>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>> var country_states_path = ''/states/''; >>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>> var country_id = $(this).val(); >>>>>>>>>>> $.ajax({ >>>>>>>>>>> type: "GET", >>>>>>>>>>> data: {country: country_id}, >>>>>>>>>>> url: country_states_path, >>>>>>>>>>> success: function(data) { >>>>>>>>>>> // Code to populate cities >>>>>>>>>>> } >>>>>>>>>>> }); >>>>>>>>>>> }); >>>>>>>>>>> }); >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>>>>>>>>> > wrote: >>>>>>>>>>> >>>>>>>>>>>> Hi Hassan, >>>>>>>>>>>> >>>>>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this is >>>>>>>>>>>> correct >>>>>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>>>>> >>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>> $.ajax({ >>>>>>>>>>>> type: "GET", >>>>>>>>>>>> url: ''/states/1'', >>>>>>>>>>>> success: function(data) { >>>>>>>>>>>> // Code >>>>>>>>>>>> } >>>>>>>>>>>> }); >>>>>>>>>>>> }); >>>>>>>>>>>> }); >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> and my clients form has state feidl like this >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> <div class="field row odd"> >>>>>>>>>>>> <%= f.label :state1 %> >>>>>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>>>>> [s.name,s.id]} %> >>>>>>>>>>>> </div> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> now i want to pass the country id and ftecth state depending on >>>>>>>>>>>> it..... do i include the above div in a prtial and what to >>>>>>>>>>>> write in >>>>>>>>>>>> the state controller..... >>>>>>>>>>>> >>>>>>>>>>>> Thanks in advance. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>> >>>>>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>>>>>>>>>> > >>>>>>>>>>>> wrote: >>>>>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>>>>> > >>>>>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>>>>> Javascript has been >>>>>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>>>>> > >>>>>>>>>>>> > So what''s the problem? What have you tried so far, and how >>>>>>>>>>>> did it >>>>>>>>>>>> > not work? >>>>>>>>>>>> > >>>>>>>>>>>> > -- >>>>>>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>>>>>> > twitter: @hassan >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Thanks & Regards, >>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> - Aziz M. Bookwala >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Thanks & Regards, >>>>>>>> Akshar Jamgaonkar >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> - Aziz M. Bookwala >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Thanks & Regards, >>>>>> Akshar Jamgaonkar >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> - Aziz M. Bookwala >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> - Aziz M. Bookwala >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > - Aziz M. Bookwala > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Not a problem. On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Aziz ....thanks a lot...really appriaciate your help > > > On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> That is fine, though you could make it more ''RESTful'' by adding it as a >> nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. >> The RailsCast is a little old, but you should get the idea. >> >> With respect to your current problem, what is the url you are using in >> your js? >> >> >> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Iam sorry i didnt get you.......... i have created a new action for the >>> ajax stuff is this approach wrong..... This is how my states controller is >>> >>> >>> >>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>> >>> class StatesController < ApplicationController >>> # GET /states >>> # GET /states.json >>> def index >>> @states = State.all >>> >>> respond_to do |format| >>> format.html # index.html.erb >>> format.json { render json: @states } >>> end >>> end >>> >>> # GET /states/1 >>> # GET /states/1.json >>> def show >>> @state = State.find(params[:id]) >>> >>> respond_to do |format| >>> format.html # show.html.erb >>> format.json { render json: @state } >>> end >>> end >>> >>> # GET /states/new >>> # GET /states/new.json >>> def new >>> @state = State.new >>> respond_to do |format| >>> format.html # new.html.erb >>> format.json { render json: @state } >>> end >>> end >>> >>> # GET /states/1/edit >>> def edit >>> @state = State.find(params[:id]) >>> end >>> >>> # POST /states >>> # POST /states.json >>> def create >>> @state = State.new(params[:state]) >>> >>> respond_to do |format| >>> if @state.save >>> format.html { redirect_to @state, notice: ''State was >>> successfully created.'' } >>> format.json { render json: @state, status: :created, location: >>> @state } >>> else >>> format.html { render action: "new" } >>> format.json { render json: @state.errors, status: >>> :unprocessable_entity } >>> end >>> end >>> end >>> >>> def countries_state >>> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) >>> respond_to do |format| >>> format.html >>> format.js >>> end >>> end >>> >>> # PUT /states/1 >>> # PUT /states/1.json >>> def update >>> @state = State.find(params[:id]) >>> >>> respond_to do |format| >>> if @state.update_attributes(params[:state]) >>> format.html { redirect_to @state, notice: ''State was >>> successfully updated.'' } >>> format.json { head :ok } >>> else >>> format.html { render action: "edit" } >>> format.json { render json: @state.errors, status: >>> :unprocessable_entity } >>> end >>> end >>> end >>> >>> # DELETE /states/1 >>> # DELETE /states/1.json >>> def destroy >>> @state = State.find(params[:id]) >>> @state.destroy >>> >>> respond_to do |format| >>> format.html { redirect_to states_url } >>> format.json { head :ok } >>> end >>> end >>> end >>> >>> >>> >>> >>> >>> >>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ >>> >>> >>> >>> >>> >>> >>> >>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> Make sure ur using the currect URL for the new action. >>>> >>>> >>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> Yea it looks like this... >>>>> >>>>> >>>>> match "/states/countries_state/:country_id" => "states#countries_state" >>>>> >>>>> resources :clients >>>>> >>>>> resources :skill_sets >>>>> >>>>> resources :technologies >>>>> >>>>> resources :level_of_contacts >>>>> >>>>> resources :states >>>>> >>>>> resources :discounts >>>>> >>>>> resources :countries >>>>> >>>>> resources :roles >>>>> >>>>> get "home/index" >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>>> > wrote: >>>>> >>>>>> Make sure this route comes before the route entry for the country >>>>>> resource. >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Yes i have added....it looks like this >>>>>>> >>>>>>> match "/states/countries_state/:country_id" => >>>>>>> "states#countries_state" >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Did you add a route for this new action? >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and in >>>>>>>>> states controller, and in application.js i have modified the path like this >>>>>>>>> var country_states_path = ''/states/countries_state/''; however on >>>>>>>>> console its giving me eroor like >>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>>>>> this...thanks a lot all of you for your help...... >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>> >>>>>>>>>> Hey AJ >>>>>>>>>> >>>>>>>>>> Yes, to serve any request made by your client, you would need >>>>>>>>>> something on the server to handle the request. >>>>>>>>>> As for rendering the dropdown, this is a pretty simple thing to >>>>>>>>>> do with jQuery. Look around, you should find something quite easily. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>> >>>>>>>>>>> Hey Aziz, >>>>>>>>>>> >>>>>>>>>>> really thanks for you repl..........so do i need to write >>>>>>>>>>> a controller action that would return me the states depending on the >>>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> AJ >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>> >>>>>>>>>>>> Hey AJ >>>>>>>>>>>> >>>>>>>>>>>> In your ajax call, you need to pass the id of the selected >>>>>>>>>>>> state if you are using a nested resource url structure. >>>>>>>>>>>> Your js would looks something like this: >>>>>>>>>>>> >>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>> var state_id = $(this).val(); >>>>>>>>>>>> $.ajax({ >>>>>>>>>>>> type: "GET", >>>>>>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>>>>>> success: function(data) { >>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>> } >>>>>>>>>>>> }); >>>>>>>>>>>> }); >>>>>>>>>>>> }); >>>>>>>>>>>> >>>>>>>>>>>> Incase you are not using nested resources, you still need to >>>>>>>>>>>> pass the state_id that was selected currently. Using the below js, in your >>>>>>>>>>>> controller, the state id would be available as params[:state] >>>>>>>>>>>> >>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>> var country_states_path = ''/states/''; >>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>> var country_id = $(this).val(); >>>>>>>>>>>> $.ajax({ >>>>>>>>>>>> type: "GET", >>>>>>>>>>>> data: {country: country_id}, >>>>>>>>>>>> url: country_states_path, >>>>>>>>>>>> success: function(data) { >>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>> } >>>>>>>>>>>> }); >>>>>>>>>>>> }); >>>>>>>>>>>> }); >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ < >>>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hi Hassan, >>>>>>>>>>>>> >>>>>>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this is >>>>>>>>>>>>> correct >>>>>>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>>>>>> >>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>> url: ''/states/1'', >>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>> // Code >>>>>>>>>>>>> } >>>>>>>>>>>>> }); >>>>>>>>>>>>> }); >>>>>>>>>>>>> }); >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> and my clients form has state feidl like this >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> <div class="field row odd"> >>>>>>>>>>>>> <%= f.label :state1 %> >>>>>>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>>>>>> [s.name,s.id]} %> >>>>>>>>>>>>> </div> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> now i want to pass the country id and ftecth state depending on >>>>>>>>>>>>> it..... do i include the above div in a prtial and what to >>>>>>>>>>>>> write in >>>>>>>>>>>>> the state controller..... >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks in advance. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>>> >>>>>>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder < >>>>>>>>>>>>> hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>>>>>>> wrote: >>>>>>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>>>>>> > >>>>>>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>>>>>> Javascript has been >>>>>>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>>>>>> > >>>>>>>>>>>>> > So what''s the problem? What have you tried so far, and how >>>>>>>>>>>>> did it >>>>>>>>>>>>> > not work? >>>>>>>>>>>>> > >>>>>>>>>>>>> > -- >>>>>>>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>>>>>>> > twitter: @hassan >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> Thanks & Regards, >>>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Thanks & Regards, >>>>>>>>> Akshar Jamgaonkar >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> - Aziz M. Bookwala >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Thanks & Regards, >>>>>>> Akshar Jamgaonkar >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> - Aziz M. Bookwala >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks & Regards, >>>>> Akshar Jamgaonkar >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> - Aziz M. Bookwala >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- - Aziz M. Bookwala -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Aziz.... Iam getting whatevr reponce iam nneding,....... Thansk a lot.....in the console in firbug when i see i get the states for a specific counytry.....The responce is like "[["Goa", 2]]" .... however whatever processing i do in application.js in not taking effect,,,,,, My application.js is $(document).ready(function() { var country_states_path = ''/states/countries_state/''; $("#client_country_id").change(function() { var country_id = $(this).val(); $.ajax({ type: "GET", data: {country: country_id}, url: country_states_path+country_id, success: function(data) { $("#client_country_id").html(data) } }); }); }); On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Not a problem. > > > On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Thanks Aziz ....thanks a lot...really appriaciate your help >> >> >> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> That is fine, though you could make it more ''RESTful'' by adding it as a >>> nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. >>> The RailsCast is a little old, but you should get the idea. >>> >>> With respect to your current problem, what is the url you are using in >>> your js? >>> >>> >>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Iam sorry i didnt get you.......... i have created a new action for the >>>> ajax stuff is this approach wrong..... This is how my states controller is >>>> >>>> >>>> >>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>> >>>> class StatesController < ApplicationController >>>> # GET /states >>>> # GET /states.json >>>> def index >>>> @states = State.all >>>> >>>> respond_to do |format| >>>> format.html # index.html.erb >>>> format.json { render json: @states } >>>> end >>>> end >>>> >>>> # GET /states/1 >>>> # GET /states/1.json >>>> def show >>>> @state = State.find(params[:id]) >>>> >>>> respond_to do |format| >>>> format.html # show.html.erb >>>> format.json { render json: @state } >>>> end >>>> end >>>> >>>> # GET /states/new >>>> # GET /states/new.json >>>> def new >>>> @state = State.new >>>> respond_to do |format| >>>> format.html # new.html.erb >>>> format.json { render json: @state } >>>> end >>>> end >>>> >>>> # GET /states/1/edit >>>> def edit >>>> @state = State.find(params[:id]) >>>> end >>>> >>>> # POST /states >>>> # POST /states.json >>>> def create >>>> @state = State.new(params[:state]) >>>> >>>> respond_to do |format| >>>> if @state.save >>>> format.html { redirect_to @state, notice: ''State was >>>> successfully created.'' } >>>> format.json { render json: @state, status: :created, location: >>>> @state } >>>> else >>>> format.html { render action: "new" } >>>> format.json { render json: @state.errors, status: >>>> :unprocessable_entity } >>>> end >>>> end >>>> end >>>> >>>> def countries_state >>>> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) >>>> respond_to do |format| >>>> format.html >>>> format.js >>>> end >>>> end >>>> >>>> # PUT /states/1 >>>> # PUT /states/1.json >>>> def update >>>> @state = State.find(params[:id]) >>>> >>>> respond_to do |format| >>>> if @state.update_attributes(params[:state]) >>>> format.html { redirect_to @state, notice: ''State was >>>> successfully updated.'' } >>>> format.json { head :ok } >>>> else >>>> format.html { render action: "edit" } >>>> format.json { render json: @state.errors, status: >>>> :unprocessable_entity } >>>> end >>>> end >>>> end >>>> >>>> # DELETE /states/1 >>>> # DELETE /states/1.json >>>> def destroy >>>> @state = State.find(params[:id]) >>>> @state.destroy >>>> >>>> respond_to do |format| >>>> format.html { redirect_to states_url } >>>> format.json { head :ok } >>>> end >>>> end >>>> end >>>> >>>> >>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> Make sure ur using the currect URL for the new action. >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> Yea it looks like this... >>>>>> >>>>>> >>>>>> match "/states/countries_state/:country_id" => >>>>>> "states#countries_state" >>>>>> >>>>>> resources :clients >>>>>> >>>>>> resources :skill_sets >>>>>> >>>>>> resources :technologies >>>>>> >>>>>> resources :level_of_contacts >>>>>> >>>>>> resources :states >>>>>> >>>>>> resources :discounts >>>>>> >>>>>> resources :countries >>>>>> >>>>>> resources :roles >>>>>> >>>>>> get "home/index" >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Make sure this route comes before the route entry for the country >>>>>>> resource. >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Yes i have added....it looks like this >>>>>>>> >>>>>>>> match "/states/countries_state/:country_id" => >>>>>>>> "states#countries_state" >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Did you add a route for this new action? >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>> >>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and in >>>>>>>>>> states controller, and in application.js i have modified the path like this >>>>>>>>>> var country_states_path = ''/states/countries_state/''; however on >>>>>>>>>> console its giving me eroor like >>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>>>>>> this...thanks a lot all of you for your help...... >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>> >>>>>>>>>>> Hey AJ >>>>>>>>>>> >>>>>>>>>>> Yes, to serve any request made by your client, you would need >>>>>>>>>>> something on the server to handle the request. >>>>>>>>>>> As for rendering the dropdown, this is a pretty simple thing to >>>>>>>>>>> do with jQuery. Look around, you should find something quite easily. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>> >>>>>>>>>>>> Hey Aziz, >>>>>>>>>>>> >>>>>>>>>>>> really thanks for you repl..........so do i need to >>>>>>>>>>>> write a controller action that would return me the states depending on the >>>>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>>>>>>> >>>>>>>>>>>> Thanks, >>>>>>>>>>>> AJ >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hey AJ >>>>>>>>>>>>> >>>>>>>>>>>>> In your ajax call, you need to pass the id of the selected >>>>>>>>>>>>> state if you are using a nested resource url structure. >>>>>>>>>>>>> Your js would looks something like this: >>>>>>>>>>>>> >>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>> var state_id = $(this).val(); >>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>>> } >>>>>>>>>>>>> }); >>>>>>>>>>>>> }); >>>>>>>>>>>>> }); >>>>>>>>>>>>> >>>>>>>>>>>>> Incase you are not using nested resources, you still need to >>>>>>>>>>>>> pass the state_id that was selected currently. Using the below js, in your >>>>>>>>>>>>> controller, the state id would be available as params[:state] >>>>>>>>>>>>> >>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>> var country_states_path = ''/states/''; >>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>> var country_id = $(this).val(); >>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>> data: {country: country_id}, >>>>>>>>>>>>> url: country_states_path, >>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>>> } >>>>>>>>>>>>> }); >>>>>>>>>>>>> }); >>>>>>>>>>>>> }); >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ < >>>>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Hassan, >>>>>>>>>>>>>> >>>>>>>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this >>>>>>>>>>>>>> is correct >>>>>>>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>>>>>>> >>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>>> url: ''/states/1'', >>>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>>> // Code >>>>>>>>>>>>>> } >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> and my clients form has state feidl like this >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> <div class="field row odd"> >>>>>>>>>>>>>> <%= f.label :state1 %> >>>>>>>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>>>>>>> [s.name,s.id]} %> >>>>>>>>>>>>>> </div> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> now i want to pass the country id and ftecth state depending >>>>>>>>>>>>>> on >>>>>>>>>>>>>> it..... do i include the above div in a prtial and what to >>>>>>>>>>>>>> write in >>>>>>>>>>>>>> the state controller..... >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks in advance. >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>>>> >>>>>>>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder < >>>>>>>>>>>>>> hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>>>>>>> Javascript has been >>>>>>>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > So what''s the problem? What have you tried so far, and how >>>>>>>>>>>>>> did it >>>>>>>>>>>>>> > not work? >>>>>>>>>>>>>> > >>>>>>>>>>>>>> > -- >>>>>>>>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>>>>>>>> > twitter: @hassan >>>>>>>>>>>>>> >>>>>>>>>>>>>> -- >>>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Thanks & Regards, >>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> - Aziz M. Bookwala >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Thanks & Regards, >>>>>>>> Akshar Jamgaonkar >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> - Aziz M. Bookwala >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Thanks & Regards, >>>>>> Akshar Jamgaonkar >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> - Aziz M. Bookwala >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> - Aziz M. Bookwala >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > - Aziz M. Bookwala > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Also in the def countries_state @state = State.where("country_id = :c_id",{:c_id => params[:country_id]}) respond_to do |format| format.html end end previously the it was format.js when nothing on the page was changing dynamically but when i make it format.html, the state drop down changes but i get all the unnecessary thing like the the entire html page. Thanks On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Aziz.... > > Iam getting whatevr reponce iam nneding,....... Thansk a lot.....in > the console in firbug when i see i get the states for a specific > counytry.....The responce is like "[["Goa", 2]]" .... however > whatever processing i do in application.js in not taking effect,,,,,, > > My application.js is > > $(document).ready(function() { > var country_states_path = ''/states/countries_state/''; > $("#client_country_id").change(function() { > var country_id = $(this).val(); > $.ajax({ > type: "GET", > data: {country: country_id}, > url: country_states_path+country_id, > success: function(data) { > $("#client_country_id").html(data) > } > }); > }); > }); > > On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Not a problem. >> >> >> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Thanks Aziz ....thanks a lot...really appriaciate your help >>> >>> >>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> That is fine, though you could make it more ''RESTful'' by adding it as a >>>> nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. >>>> The RailsCast is a little old, but you should get the idea. >>>> >>>> With respect to your current problem, what is the url you are using in >>>> your js? >>>> >>>> >>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> Iam sorry i didnt get you.......... i have created a new action for >>>>> the ajax stuff is this approach wrong..... This is how my states controller >>>>> is >>>>> >>>>> >>>>> >>>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>>> >>>>> class StatesController < ApplicationController >>>>> # GET /states >>>>> # GET /states.json >>>>> def index >>>>> @states = State.all >>>>> >>>>> respond_to do |format| >>>>> format.html # index.html.erb >>>>> format.json { render json: @states } >>>>> end >>>>> end >>>>> >>>>> # GET /states/1 >>>>> # GET /states/1.json >>>>> def show >>>>> @state = State.find(params[:id]) >>>>> >>>>> respond_to do |format| >>>>> format.html # show.html.erb >>>>> format.json { render json: @state } >>>>> end >>>>> end >>>>> >>>>> # GET /states/new >>>>> # GET /states/new.json >>>>> def new >>>>> @state = State.new >>>>> respond_to do |format| >>>>> format.html # new.html.erb >>>>> format.json { render json: @state } >>>>> end >>>>> end >>>>> >>>>> # GET /states/1/edit >>>>> def edit >>>>> @state = State.find(params[:id]) >>>>> end >>>>> >>>>> # POST /states >>>>> # POST /states.json >>>>> def create >>>>> @state = State.new(params[:state]) >>>>> >>>>> respond_to do |format| >>>>> if @state.save >>>>> format.html { redirect_to @state, notice: ''State was >>>>> successfully created.'' } >>>>> format.json { render json: @state, status: :created, location: >>>>> @state } >>>>> else >>>>> format.html { render action: "new" } >>>>> format.json { render json: @state.errors, status: >>>>> :unprocessable_entity } >>>>> end >>>>> end >>>>> end >>>>> >>>>> def countries_state >>>>> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) >>>>> respond_to do |format| >>>>> format.html >>>>> format.js >>>>> end >>>>> end >>>>> >>>>> # PUT /states/1 >>>>> # PUT /states/1.json >>>>> def update >>>>> @state = State.find(params[:id]) >>>>> >>>>> respond_to do |format| >>>>> if @state.update_attributes(params[:state]) >>>>> format.html { redirect_to @state, notice: ''State was >>>>> successfully updated.'' } >>>>> format.json { head :ok } >>>>> else >>>>> format.html { render action: "edit" } >>>>> format.json { render json: @state.errors, status: >>>>> :unprocessable_entity } >>>>> end >>>>> end >>>>> end >>>>> >>>>> # DELETE /states/1 >>>>> # DELETE /states/1.json >>>>> def destroy >>>>> @state = State.find(params[:id]) >>>>> @state.destroy >>>>> >>>>> respond_to do |format| >>>>> format.html { redirect_to states_url } >>>>> format.json { head :ok } >>>>> end >>>>> end >>>>> end >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>>> > wrote: >>>>> >>>>>> Make sure ur using the currect URL for the new action. >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Yea it looks like this... >>>>>>> >>>>>>> >>>>>>> match "/states/countries_state/:country_id" => >>>>>>> "states#countries_state" >>>>>>> >>>>>>> resources :clients >>>>>>> >>>>>>> resources :skill_sets >>>>>>> >>>>>>> resources :technologies >>>>>>> >>>>>>> resources :level_of_contacts >>>>>>> >>>>>>> resources :states >>>>>>> >>>>>>> resources :discounts >>>>>>> >>>>>>> resources :countries >>>>>>> >>>>>>> resources :roles >>>>>>> >>>>>>> get "home/index" >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Make sure this route comes before the route entry for the country >>>>>>>> resource. >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Yes i have added....it looks like this >>>>>>>>> >>>>>>>>> match "/states/countries_state/:country_id" => >>>>>>>>> "states#countries_state" >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>> >>>>>>>>>> Did you add a route for this new action? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>> >>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and >>>>>>>>>>> in states controller, and in application.js i have modified the path like >>>>>>>>>>> this >>>>>>>>>>> var country_states_path = ''/states/countries_state/''; however on >>>>>>>>>>> console its giving me eroor like >>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>>>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>>>>>>> this...thanks a lot all of you for your help...... >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>> >>>>>>>>>>>> Hey AJ >>>>>>>>>>>> >>>>>>>>>>>> Yes, to serve any request made by your client, you would need >>>>>>>>>>>> something on the server to handle the request. >>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple thing to >>>>>>>>>>>> do with jQuery. Look around, you should find something quite easily. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hey Aziz, >>>>>>>>>>>>> >>>>>>>>>>>>> really thanks for you repl..........so do i need to >>>>>>>>>>>>> write a controller action that would return me the states depending on the >>>>>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> AJ >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hey AJ >>>>>>>>>>>>>> >>>>>>>>>>>>>> In your ajax call, you need to pass the id of the selected >>>>>>>>>>>>>> state if you are using a nested resource url structure. >>>>>>>>>>>>>> Your js would looks something like this: >>>>>>>>>>>>>> >>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>>> var state_id = $(this).val(); >>>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>>>> } >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> >>>>>>>>>>>>>> Incase you are not using nested resources, you still need to >>>>>>>>>>>>>> pass the state_id that was selected currently. Using the below js, in your >>>>>>>>>>>>>> controller, the state id would be available as params[:state] >>>>>>>>>>>>>> >>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>> var country_states_path = ''/states/''; >>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>>> var country_id = $(this).val(); >>>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>>> data: {country: country_id}, >>>>>>>>>>>>>> url: country_states_path, >>>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>>>> } >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> }); >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ < >>>>>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hi Hassan, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this >>>>>>>>>>>>>>> is correct >>>>>>>>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>>>> url: ''/states/1'', >>>>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>>>> // Code >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> and my clients form has state feidl like this >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> <div class="field row odd"> >>>>>>>>>>>>>>> <%= f.label :state1 %> >>>>>>>>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>>>>>>>> [s.name,s.id]} %> >>>>>>>>>>>>>>> </div> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> now i want to pass the country id and ftecth state depending >>>>>>>>>>>>>>> on >>>>>>>>>>>>>>> it..... do i include the above div in a prtial and what to >>>>>>>>>>>>>>> write in >>>>>>>>>>>>>>> the state controller..... >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks in advance. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder < >>>>>>>>>>>>>>> hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>>>>>>>> Javascript has been >>>>>>>>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > So what''s the problem? What have you tried so far, and how >>>>>>>>>>>>>>> did it >>>>>>>>>>>>>>> > not work? >>>>>>>>>>>>>>> > >>>>>>>>>>>>>>> > -- >>>>>>>>>>>>>>> > Hassan Schroeder ------------------------ hassan.schroe... >>>>>>>>>>>>>>> @gmail.comhttp://about.me/hassanschroeder >>>>>>>>>>>>>>> > twitter: @hassan >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> -- >>>>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> -- >>>>>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>>>>> >>>>>>>>>>>>>> -- >>>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> Thanks & Regards, >>>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Thanks & Regards, >>>>>>>>> Akshar Jamgaonkar >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> - Aziz M. Bookwala >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Thanks & Regards, >>>>>>> Akshar Jamgaonkar >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> - Aziz M. Bookwala >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks & Regards, >>>>> Akshar Jamgaonkar >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> - Aziz M. Bookwala >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> - Aziz M. Bookwala >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi all, I have succesfully got a responce like this as to what i want , this is the ouptut in my fireofx console. <select id="states_state_id" name="states[state_id]"><option value="1">Maharashtra</option></select>. but the html on the page is not updating.......any reson why this could be ...thanks a lot.... On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Also in the def countries_state > @state = State.where("country_id = :c_id",{:c_id => params[:country_id]}) > respond_to do |format| > format.html > end > end > > previously the it was format.js when nothing on the page was changing > dynamically but when i make it format.html, the state drop down changes but > i get all the unnecessary thing like the the entire html page. > > > Thanks > > > On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi Aziz.... >> >> Iam getting whatevr reponce iam nneding,....... Thansk a lot.....in >> the console in firbug when i see i get the states for a specific >> counytry.....The responce is like "[["Goa", 2]]" .... however >> whatever processing i do in application.js in not taking effect,,,,,, >> >> My application.js is >> >> $(document).ready(function() { >> var country_states_path = ''/states/countries_state/''; >> $("#client_country_id").change(function() { >> var country_id = $(this).val(); >> $.ajax({ >> type: "GET", >> data: {country: country_id}, >> url: country_states_path+country_id, >> success: function(data) { >> $("#client_country_id").html(data) >> } >> }); >> }); >> }); >> >> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> Not a problem. >>> >>> >>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Thanks Aziz ....thanks a lot...really appriaciate your help >>>> >>>> >>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> That is fine, though you could make it more ''RESTful'' by adding it as >>>>> a nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. >>>>> The RailsCast is a little old, but you should get the idea. >>>>> >>>>> With respect to your current problem, what is the url you are using in >>>>> your js? >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> Iam sorry i didnt get you.......... i have created a new action for >>>>>> the ajax stuff is this approach wrong..... This is how my states controller >>>>>> is >>>>>> >>>>>> >>>>>> >>>>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>>>> >>>>>> class StatesController < ApplicationController >>>>>> # GET /states >>>>>> # GET /states.json >>>>>> def index >>>>>> @states = State.all >>>>>> >>>>>> respond_to do |format| >>>>>> format.html # index.html.erb >>>>>> format.json { render json: @states } >>>>>> end >>>>>> end >>>>>> >>>>>> # GET /states/1 >>>>>> # GET /states/1.json >>>>>> def show >>>>>> @state = State.find(params[:id]) >>>>>> >>>>>> respond_to do |format| >>>>>> format.html # show.html.erb >>>>>> format.json { render json: @state } >>>>>> end >>>>>> end >>>>>> >>>>>> # GET /states/new >>>>>> # GET /states/new.json >>>>>> def new >>>>>> @state = State.new >>>>>> respond_to do |format| >>>>>> format.html # new.html.erb >>>>>> format.json { render json: @state } >>>>>> end >>>>>> end >>>>>> >>>>>> # GET /states/1/edit >>>>>> def edit >>>>>> @state = State.find(params[:id]) >>>>>> end >>>>>> >>>>>> # POST /states >>>>>> # POST /states.json >>>>>> def create >>>>>> @state = State.new(params[:state]) >>>>>> >>>>>> respond_to do |format| >>>>>> if @state.save >>>>>> format.html { redirect_to @state, notice: ''State was >>>>>> successfully created.'' } >>>>>> format.json { render json: @state, status: :created, >>>>>> location: @state } >>>>>> else >>>>>> format.html { render action: "new" } >>>>>> format.json { render json: @state.errors, status: >>>>>> :unprocessable_entity } >>>>>> end >>>>>> end >>>>>> end >>>>>> >>>>>> def countries_state >>>>>> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) >>>>>> respond_to do |format| >>>>>> format.html >>>>>> format.js >>>>>> end >>>>>> end >>>>>> >>>>>> # PUT /states/1 >>>>>> # PUT /states/1.json >>>>>> def update >>>>>> @state = State.find(params[:id]) >>>>>> >>>>>> respond_to do |format| >>>>>> if @state.update_attributes(params[:state]) >>>>>> format.html { redirect_to @state, notice: ''State was >>>>>> successfully updated.'' } >>>>>> format.json { head :ok } >>>>>> else >>>>>> format.html { render action: "edit" } >>>>>> format.json { render json: @state.errors, status: >>>>>> :unprocessable_entity } >>>>>> end >>>>>> end >>>>>> end >>>>>> >>>>>> # DELETE /states/1 >>>>>> # DELETE /states/1.json >>>>>> def destroy >>>>>> @state = State.find(params[:id]) >>>>>> @state.destroy >>>>>> >>>>>> respond_to do |format| >>>>>> format.html { redirect_to states_url } >>>>>> format.json { head :ok } >>>>>> end >>>>>> end >>>>>> end >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < >>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Make sure ur using the currect URL for the new action. >>>>>>> >>>>>>> >>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Yea it looks like this... >>>>>>>> >>>>>>>> >>>>>>>> match "/states/countries_state/:country_id" => >>>>>>>> "states#countries_state" >>>>>>>> >>>>>>>> resources :clients >>>>>>>> >>>>>>>> resources :skill_sets >>>>>>>> >>>>>>>> resources :technologies >>>>>>>> >>>>>>>> resources :level_of_contacts >>>>>>>> >>>>>>>> resources :states >>>>>>>> >>>>>>>> resources :discounts >>>>>>>> >>>>>>>> resources :countries >>>>>>>> >>>>>>>> resources :roles >>>>>>>> >>>>>>>> get "home/index" >>>>>>>> >>>>>>>> >>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Make sure this route comes before the route entry for the country >>>>>>>>> resource. >>>>>>>>> >>>>>>>>> >>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>> >>>>>>>>>> Yes i have added....it looks like this >>>>>>>>>> >>>>>>>>>> match "/states/countries_state/:country_id" => >>>>>>>>>> "states#countries_state" >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>> >>>>>>>>>>> Did you add a route for this new action? >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>> >>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and >>>>>>>>>>>> in states controller, and in application.js i have modified the path like >>>>>>>>>>>> this >>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; however >>>>>>>>>>>> on console its giving me eroor like >>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>>>>>>>> this...thanks a lot all of you for your help...... >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hey AJ >>>>>>>>>>>>> >>>>>>>>>>>>> Yes, to serve any request made by your client, you would need >>>>>>>>>>>>> something on the server to handle the request. >>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple thing >>>>>>>>>>>>> to do with jQuery. Look around, you should find something quite easily. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hey Aziz, >>>>>>>>>>>>>> >>>>>>>>>>>>>> really thanks for you repl..........so do i need to >>>>>>>>>>>>>> write a controller action that would return me the states depending on the >>>>>>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>> AJ >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>>>>>>>> aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hey AJ >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the selected >>>>>>>>>>>>>>> state if you are using a nested resource url structure. >>>>>>>>>>>>>>> Your js would looks something like this: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>>>> var state_id = $(this).val(); >>>>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>>>> url: country_states_path.replace(":id", id), >>>>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Incase you are not using nested resources, you still need to >>>>>>>>>>>>>>> pass the state_id that was selected currently. Using the below js, in your >>>>>>>>>>>>>>> controller, the state id would be available as params[:state] >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>>> var country_states_path = ''/states/''; >>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>>>> var country_id = $(this).val(); >>>>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>>>> data: {country: country_id}, >>>>>>>>>>>>>>> url: country_states_path, >>>>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>>>> // Code to populate cities >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 12:42 PM, AJ < >>>>>>>>>>>>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Hi Hassan, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> I am Bit of a novoice to this...... iam nt sure wether this >>>>>>>>>>>>>>>> is correct >>>>>>>>>>>>>>>> approach...in my application.js file i have wriiten >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>>>>>>>>>>>> $.ajax({ >>>>>>>>>>>>>>>> type: "GET", >>>>>>>>>>>>>>>> url: ''/states/1'', >>>>>>>>>>>>>>>> success: function(data) { >>>>>>>>>>>>>>>> // Code >>>>>>>>>>>>>>>> } >>>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>>> }); >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> and my clients form has state feidl like this >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> <div class="field row odd"> >>>>>>>>>>>>>>>> <%= f.label :state1 %> >>>>>>>>>>>>>>>> <%= f.select ''state_id'', State.find(:all).collect{|s| >>>>>>>>>>>>>>>> [s.name,s.id]} %> >>>>>>>>>>>>>>>> </div> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> now i want to pass the country id and ftecth state >>>>>>>>>>>>>>>> depending on >>>>>>>>>>>>>>>> it..... do i include the above div in a prtial and what to >>>>>>>>>>>>>>>> write in >>>>>>>>>>>>>>>> the state controller..... >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks in advance. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On May 2, 7:14 pm, Hassan Schroeder < >>>>>>>>>>>>>>>> hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>>> > On Wed, May 2, 2012 at 7:06 AM, akshar jamgaonkar >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>>>>>>>>>> > > i have gone through this but it has an example where >>>>>>>>>>>>>>>> Javascript has been >>>>>>>>>>>>>>>> > > used , i want to use AJAX and JQuery, >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > So what''s the problem? What have you tried so far, and >>>>>>>>>>>>>>>> how did it >>>>>>>>>>>>>>>> > not work? >>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>> > -- >>>>>>>>>>>>>>>> > Hassan Schroeder ------------------------ >>>>>>>>>>>>>>>> hassan.schroe...-Re5JQEeQqe80Tx58lXaADg@public.gmane.org://about.me/hassanschroeder >>>>>>>>>>>>>>>> > twitter: @hassan >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> -- >>>>>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> -- >>>>>>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> -- >>>>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> -- >>>>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>>>>>> >>>>>>>>>>>>>> -- >>>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> Thanks & Regards, >>>>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> - Aziz M. Bookwala >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Thanks & Regards, >>>>>>>>>> Akshar Jamgaonkar >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> - Aziz M. Bookwala >>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Thanks & Regards, >>>>>>>> Akshar Jamgaonkar >>>>>>>> >>>>>>>> -- >>>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> - Aziz M. Bookwala >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Thanks & Regards, >>>>>> Akshar Jamgaonkar >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> - Aziz M. Bookwala >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> - Aziz M. Bookwala >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> > > > -- > Thanks & Regards, > Akshar Jamgaonkar > >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello All, ill just summarize everything in this message..kindly suggest as to what might be wrong ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Iam trying to achiev a functionlity of state drop down been populated on click of country........i have achieved almost 90% of this......iam getting appropriate responce in my firebug. responce is like this when i click india..... <select id="states_state_id" name="states[state_id]"><option value="2">Goa</option></select> my application .js looks like this $(document).ready(function() { var country_states_path = ''/states/countries_state/''; $("#client_country_id").change(function() { var country_id = $(this).val(); $.ajax({ type: "GET", data: {country: country_id}, url: country_states_path+country_id, success: function(data) { $("#client_state_id").html(data) } }); }); }); the controller state has an action like this def countries_state @state = State.where("country_id = :c_id",{:c_id => params[:country_id]}) respond_to do |format| format.js end end and template for this action is like <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) %> However i am getting the response in firebug but the html on page is not updated. Iam trying to find but iam stuck as iam a bit new to all this. Please suggest as to what might be wrong. thanks a lot Thanks & Regards, Akshar ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > I have succesfully got a responce like this as to what i want , this is the > ouptut in my fireofx console. > > <select id="states_state_id" name="states[state_id]"><option > value="1">Maharashtra</option></select>. > > but the html on the page is not updating.......any reson why this could be > ...thanks a lot.... > > On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < > > > > > > > > akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Also in the def countries_state > > @state = State.where("country_id = :c_id",{:c_id => params[:country_id]}) > > respond_to do |format| > > format.html > > end > > end > > > previously the it was format.js when nothing on the page was changing > > dynamically but when i make it format.html, the state drop down changes but > > i get all the unnecessary thing like the the entire html page. > > > Thanks > > > On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < > > akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> Hi Aziz.... > > >> Iam getting whatevr reponce iam nneding,....... Thansk a lot.....in > >> the console in firbug when i see i get the states for a specific > >> counytry.....The responce is like "[["Goa", 2]]" .... however > >> whatever processing i do in application.js in not taking effect,,,,,, > > >> My application.js is > > >> $(document).ready(function() { > >> var country_states_path = ''/states/countries_state/''; > >> $("#client_country_id").change(function() { > >> var country_id = $(this).val(); > >> $.ajax({ > >> type: "GET", > >> data: {country: country_id}, > >> url: country_states_path+country_id, > >> success: function(data) { > >> $("#client_country_id").html(data) > >> } > >> }); > >> }); > >> }); > > >> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala <aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > >>> Not a problem. > > >>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < > >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>> Thanks Aziz ....thanks a lot...really appriaciate your help > > >>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookw...@gmail.com>wrote: > > >>>>> That is fine, though you could make it more ''RESTful'' by adding it as > >>>>> a nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. > >>>>> The RailsCast is a little old, but you should get the idea. > > >>>>> With respect to your current problem, what is the url you are using in > >>>>> your js? > > >>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < > >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>> Iam sorry i didnt get you.......... i have created a new action for > >>>>>> the ajax stuff is this approach wrong..... This is how my states controller > >>>>>> is > > >>>>>> --------------------------------------------------------------------------- --------------------------------------------------------------------------- ----------------------------------- > > >>>>>> class StatesController < ApplicationController > >>>>>> # GET /states > >>>>>> # GET /states.json > >>>>>> def index > >>>>>> @states = State.all > > >>>>>> respond_to do |format| > >>>>>> format.html # index.html.erb > >>>>>> format.json { render json: @states } > >>>>>> end > >>>>>> end > > >>>>>> # GET /states/1 > >>>>>> # GET /states/1.json > >>>>>> def show > >>>>>> @state = State.find(params[:id]) > > >>>>>> respond_to do |format| > >>>>>> format.html # show.html.erb > >>>>>> format.json { render json: @state } > >>>>>> end > >>>>>> end > > >>>>>> # GET /states/new > >>>>>> # GET /states/new.json > >>>>>> def new > >>>>>> @state = State.new > >>>>>> respond_to do |format| > >>>>>> format.html # new.html.erb > >>>>>> format.json { render json: @state } > >>>>>> end > >>>>>> end > > >>>>>> # GET /states/1/edit > >>>>>> def edit > >>>>>> @state = State.find(params[:id]) > >>>>>> end > > >>>>>> # POST /states > >>>>>> # POST /states.json > >>>>>> def create > >>>>>> @state = State.new(params[:state]) > > >>>>>> respond_to do |format| > >>>>>> if @state.save > >>>>>> format.html { redirect_to @state, notice: ''State was > >>>>>> successfully created.'' } > >>>>>> format.json { render json: @state, status: :created, > >>>>>> location: @state } > >>>>>> else > >>>>>> format.html { render action: "new" } > >>>>>> format.json { render json: @state.errors, status: > >>>>>> :unprocessable_entity } > >>>>>> end > >>>>>> end > >>>>>> end > > >>>>>> def countries_state > >>>>>> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) > >>>>>> respond_to do |format| > >>>>>> format.html > >>>>>> format.js > >>>>>> end > >>>>>> end > > >>>>>> # PUT /states/1 > >>>>>> # PUT /states/1.json > >>>>>> def update > >>>>>> @state = State.find(params[:id]) > > >>>>>> respond_to do |format| > >>>>>> if @state.update_attributes(params[:state]) > >>>>>> format.html { redirect_to @state, notice: ''State was > >>>>>> successfully updated.'' } > >>>>>> format.json { head :ok } > >>>>>> else > >>>>>> format.html { render action: "edit" } > >>>>>> format.json { render json: @state.errors, status: > >>>>>> :unprocessable_entity } > >>>>>> end > >>>>>> end > >>>>>> end > > >>>>>> # DELETE /states/1 > >>>>>> # DELETE /states/1.json > >>>>>> def destroy > >>>>>> @state = State.find(params[:id]) > >>>>>> @state.destroy > > >>>>>> respond_to do |format| > >>>>>> format.html { redirect_to states_url } > >>>>>> format.json { head :ok } > >>>>>> end > >>>>>> end > >>>>>> end > > >>>>>> --------------------------------------------------------------------------- --------------------------------------------------------------------------- ------------------------------------ > > >>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < > >>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>> Make sure ur using the currect URL for the new action. > > >>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < > >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>> Yea it looks like this... > > >>>>>>>> match "/states/countries_state/:country_id" => > >>>>>>>> "states#countries_state" > > >>>>>>>> resources :clients > > >>>>>>>> resources :skill_sets > > >>>>>>>> resources :technologies > > >>>>>>>> resources :level_of_contacts > > >>>>>>>> resources :states > > >>>>>>>> resources :discounts > > >>>>>>>> resources :countries > > >>>>>>>> resources :roles > > >>>>>>>> get "home/index" > > >>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < > >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>>> Make sure this route comes before the route entry for the country > >>>>>>>>> resource. > > >>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < > >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>>>> Yes i have added....it looks like this > > >>>>>>>>>> match "/states/countries_state/:country_id" => > >>>>>>>>>> "states#countries_state" > > >>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < > >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>>>>> Did you add a route for this new action? > > >>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < > >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and > >>>>>>>>>>>> in states controller, and in application.js i have modified the path like > >>>>>>>>>>>> this > >>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; however > >>>>>>>>>>>> on console its giving me eroor like > >>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam > >>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new to all > >>>>>>>>>>>> this...thanks a lot all of you for your help...... > > >>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < > >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>>>>>>> Hey AJ > > >>>>>>>>>>>>> Yes, to serve any request made by your client, you would need > >>>>>>>>>>>>> something on the server to handle the request. > >>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple thing > >>>>>>>>>>>>> to do with jQuery. Look around, you should find something quite easily. > > >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < > >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>>>>>>>> Hey Aziz, > > >>>>>>>>>>>>>> really thanks for you repl..........so do i need to > >>>>>>>>>>>>>> write a controller action that would return me the states depending on the > >>>>>>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... > > >>>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>>> AJ > > >>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < > >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>>>>>>>>>>>>> Hey AJ > > >>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the selected > >>>>>>>>>>>>>>> state if you are using a nested resource url structure. > >>>>>>>>>>>>>>> Your js would looks something like this: > > >>>>>>>>>>>>>>> $(document).ready(function() { > >>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; > >>>>>>>>>>>>>>> $("#client_country_id").change(function() { > > ... > > read more »-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello All, > > ill just summarize everything in this message..kindly suggest as to > what might be wrongDo you have a div with the id of "client_state_id"? What do you get if you run $("#client_state_id") in firebug? Jeremy Walker> > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Iam trying to achiev a functionlity of state drop down > been populated on click of country........i have achieved almost 90% > of this......iam getting appropriate responce in my firebug. responce > is like this when i click india..... > > <select id="states_state_id" name="states[state_id]"><option > value="2">Goa</option></select> > > > my application .js looks like this > > $(document).ready(function() { > var country_states_path = ''/states/countries_state/''; > $("#client_country_id").change(function() { > var country_id = $(this).val(); > $.ajax({ > type: "GET", > data: {country: country_id}, > url: country_states_path+country_id, > success: function(data) { > $("#client_state_id").html(data) > } > }); > }); > }); > > > > the controller state has an action like this > > def countries_state > @state = State.where("country_id = :c_id",{:c_id => > params[:country_id]}) > respond_to do |format| > format.js > end > end > > > > and template for this action is like > > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) %> > > > However i am getting the response in firebug but the html on page is > not updated. Iam trying to find but iam stuck as iam a bit new to all > this. > > > Please suggest as to what might be wrong. thanks a lot > > > Thanks & Regards, > Akshar > > > > > > > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> Hi all, >> >> I have succesfully got a responce like this as to what i want , this is the >> ouptut in my fireofx console. >> >> <select id="states_state_id" name="states[state_id]"><option >> value="1">Maharashtra</option></select>. >> >> but the html on the page is not updating.......any reson why this could be >> ...thanks a lot.... >> >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < >> >> >> >> >> >> >> >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> Also in the def countries_state >>> @state = State.where("country_id = :c_id",{:c_id => params[:country_id]}) >>> respond_to do |format| >>> format.html >>> end >>> end >> >>> previously the it was format.js when nothing on the page was changing >>> dynamically but when i make it format.html, the state drop down changes but >>> i get all the unnecessary thing like the the entire html page. >> >>> Thanks >> >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>> Hi Aziz.... >> >>>> Iam getting whatevr reponce iam nneding,....... Thansk a lot.....in >>>> the console in firbug when i see i get the states for a specific >>>> counytry.....The responce is like "[["Goa", 2]]" .... however >>>> whatever processing i do in application.js in not taking effect,,,,,, >> >>>> My application.js is >> >>>> $(document).ready(function() { >>>> var country_states_path = ''/states/countries_state/''; >>>> $("#client_country_id").change(function() { >>>> var country_id = $(this).val(); >>>> $.ajax({ >>>> type: "GET", >>>> data: {country: country_id}, >>>> url: country_states_path+country_id, >>>> success: function(data) { >>>> $("#client_country_id").html(data) >>>> } >>>> }); >>>> }); >>>> }); >> >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala <aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>>>> Not a problem. >> >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help >> >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookw...@gmail.com>wrote: >> >>>>>>> That is fine, though you could make it more ''RESTful'' by adding it as >>>>>>> a nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. >>>>>>> The RailsCast is a little old, but you should get the idea. >> >>>>>>> With respect to your current problem, what is the url you are using in >>>>>>> your js? >> >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>> Iam sorry i didnt get you.......... i have created a new action for >>>>>>>> the ajax stuff is this approach wrong..... This is how my states controller >>>>>>>> is >> >>>>>>>> --------------------------------------------------------------------------- --------------------------------------------------------------------------- ----------------------------------- >> >>>>>>>> class StatesController < ApplicationController >>>>>>>> # GET /states >>>>>>>> # GET /states.json >>>>>>>> def index >>>>>>>> @states = State.all >> >>>>>>>> respond_to do |format| >>>>>>>> format.html # index.html.erb >>>>>>>> format.json { render json: @states } >>>>>>>> end >>>>>>>> end >> >>>>>>>> # GET /states/1 >>>>>>>> # GET /states/1.json >>>>>>>> def show >>>>>>>> @state = State.find(params[:id]) >> >>>>>>>> respond_to do |format| >>>>>>>> format.html # show.html.erb >>>>>>>> format.json { render json: @state } >>>>>>>> end >>>>>>>> end >> >>>>>>>> # GET /states/new >>>>>>>> # GET /states/new.json >>>>>>>> def new >>>>>>>> @state = State.new >>>>>>>> respond_to do |format| >>>>>>>> format.html # new.html.erb >>>>>>>> format.json { render json: @state } >>>>>>>> end >>>>>>>> end >> >>>>>>>> # GET /states/1/edit >>>>>>>> def edit >>>>>>>> @state = State.find(params[:id]) >>>>>>>> end >> >>>>>>>> # POST /states >>>>>>>> # POST /states.json >>>>>>>> def create >>>>>>>> @state = State.new(params[:state]) >> >>>>>>>> respond_to do |format| >>>>>>>> if @state.save >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>>>>>> successfully created.'' } >>>>>>>> format.json { render json: @state, status: :created, >>>>>>>> location: @state } >>>>>>>> else >>>>>>>> format.html { render action: "new" } >>>>>>>> format.json { render json: @state.errors, status: >>>>>>>> :unprocessable_entity } >>>>>>>> end >>>>>>>> end >>>>>>>> end >> >>>>>>>> def countries_state >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) >>>>>>>> respond_to do |format| >>>>>>>> format.html >>>>>>>> format.js >>>>>>>> end >>>>>>>> end >> >>>>>>>> # PUT /states/1 >>>>>>>> # PUT /states/1.json >>>>>>>> def update >>>>>>>> @state = State.find(params[:id]) >> >>>>>>>> respond_to do |format| >>>>>>>> if @state.update_attributes(params[:state]) >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>>>>>> successfully updated.'' } >>>>>>>> format.json { head :ok } >>>>>>>> else >>>>>>>> format.html { render action: "edit" } >>>>>>>> format.json { render json: @state.errors, status: >>>>>>>> :unprocessable_entity } >>>>>>>> end >>>>>>>> end >>>>>>>> end >> >>>>>>>> # DELETE /states/1 >>>>>>>> # DELETE /states/1.json >>>>>>>> def destroy >>>>>>>> @state = State.find(params[:id]) >>>>>>>> @state.destroy >> >>>>>>>> respond_to do |format| >>>>>>>> format.html { redirect_to states_url } >>>>>>>> format.json { head :ok } >>>>>>>> end >>>>>>>> end >>>>>>>> end >> >>>>>>>> --------------------------------------------------------------------------- --------------------------------------------------------------------------- ------------------------------------ >> >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>> Make sure ur using the currect URL for the new action. >> >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>> Yea it looks like this... >> >>>>>>>>>> match "/states/countries_state/:country_id" => >>>>>>>>>> "states#countries_state" >> >>>>>>>>>> resources :clients >> >>>>>>>>>> resources :skill_sets >> >>>>>>>>>> resources :technologies >> >>>>>>>>>> resources :level_of_contacts >> >>>>>>>>>> resources :states >> >>>>>>>>>> resources :discounts >> >>>>>>>>>> resources :countries >> >>>>>>>>>> resources :roles >> >>>>>>>>>> get "home/index" >> >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>>> Make sure this route comes before the route entry for the country >>>>>>>>>>> resource. >> >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>>>> Yes i have added....it looks like this >> >>>>>>>>>>>> match "/states/countries_state/:country_id" => >>>>>>>>>>>> "states#countries_state" >> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>>>>> Did you add a route for this new action? >> >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and >>>>>>>>>>>>>> in states controller, and in application.js i have modified the path like >>>>>>>>>>>>>> this >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; however >>>>>>>>>>>>>> on console its giving me eroor like >>>>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new to all >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... >> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>>>>>>> Hey AJ >> >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you would need >>>>>>>>>>>>>>> something on the server to handle the request. >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple thing >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find something quite easily. >> >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>>>>>>>> Hey Aziz, >> >>>>>>>>>>>>>>>> really thanks for you repl..........so do i need to >>>>>>>>>>>>>>>> write a controller action that would return me the states depending on the >>>>>>>>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... >> >>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>> AJ >> >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>>>>>>>>>>>>>>> Hey AJ >> >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the selected >>>>>>>>>>>>>>>>> state if you are using a nested resource url structure. >>>>>>>>>>>>>>>>> Your js would looks something like this: >> >>>>>>>>>>>>>>>>> $(document).ready(function() { >>>>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { >> >> ... >> >> read more » > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Yes i have a Select box with this id = "client_state_id" .. when i run $("#client_state_id") the select drop down control gets highlighted. Thanks On Thu, May 3, 2012 at 6:46 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello All, > > > > ill just summarize everything in this message..kindly suggest as to > > what might be wrong > > Do you have a div with the id of "client_state_id"? What do you get if you > run $("#client_state_id") in firebug? > > Jeremy Walker > > > > > > > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Iam trying to achiev a functionlity of state drop down > > been populated on click of country........i have achieved almost 90% > > of this......iam getting appropriate responce in my firebug. responce > > is like this when i click india..... > > > > <select id="states_state_id" name="states[state_id]"><option > > value="2">Goa</option></select> > > > > > > my application .js looks like this > > > > $(document).ready(function() { > > var country_states_path = ''/states/countries_state/''; > > $("#client_country_id").change(function() { > > var country_id = $(this).val(); > > $.ajax({ > > type: "GET", > > data: {country: country_id}, > > url: country_states_path+country_id, > > success: function(data) { > > $("#client_state_id").html(data) > > } > > }); > > }); > > }); > > > > > > > > the controller state has an action like this > > > > def countries_state > > @state = State.where("country_id = :c_id",{:c_id => > > params[:country_id]}) > > respond_to do |format| > > format.js > > end > > end > > > > > > > > and template for this action is like > > > > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) %> > > > > > > However i am getting the response in firebug but the html on page is > > not updated. Iam trying to find but iam stuck as iam a bit new to all > > this. > > > > > > Please suggest as to what might be wrong. thanks a lot > > > > > > Thanks & Regards, > > Akshar > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > > > > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> Hi all, > >> > >> I have succesfully got a responce like this as to what i want , this is > the > >> ouptut in my fireofx console. > >> > >> <select id="states_state_id" name="states[state_id]"><option > >> value="1">Maharashtra</option></select>. > >> > >> but the html on the page is not updating.......any reson why this could > be > >> ...thanks a lot.... > >> > >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < > >> > >> > >> > >> > >> > >> > >> > >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>> Also in the def countries_state > >>> @state = State.where("country_id = :c_id",{:c_id => > params[:country_id]}) > >>> respond_to do |format| > >>> format.html > >>> end > >>> end > >> > >>> previously the it was format.js when nothing on the page was changing > >>> dynamically but when i make it format.html, the state drop down > changes but > >>> i get all the unnecessary thing like the the entire html page. > >> > >>> Thanks > >> > >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < > >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>> Hi Aziz.... > >> > >>>> Iam getting whatevr reponce iam nneding,....... Thansk a > lot.....in > >>>> the console in firbug when i see i get the states for a specific > >>>> counytry.....The responce is like "[["Goa", 2]]" .... > however > >>>> whatever processing i do in application.js in not taking effect,,,,,, > >> > >>>> My application.js is > >> > >>>> $(document).ready(function() { > >>>> var country_states_path = ''/states/countries_state/''; > >>>> $("#client_country_id").change(function() { > >>>> var country_id = $(this).val(); > >>>> $.ajax({ > >>>> type: "GET", > >>>> data: {country: country_id}, > >>>> url: country_states_path+country_id, > >>>> success: function(data) { > >>>> $("#client_country_id").html(data) > >>>> } > >>>> }); > >>>> }); > >>>> }); > >> > >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala < > aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> > >>>>> Not a problem. > >> > >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < > >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help > >> > >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala < > aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> > >>>>>>> That is fine, though you could make it more ''RESTful'' by adding it > as > >>>>>>> a nested resource. You can read about that here< > http://railscasts.com/episodes/139-nested-resources>. > >>>>>>> The RailsCast is a little old, but you should get the idea. > >> > >>>>>>> With respect to your current problem, what is the url you are > using in > >>>>>>> your js? > >> > >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < > >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>> Iam sorry i didnt get you.......... i have created a new action > for > >>>>>>>> the ajax stuff is this approach wrong..... This is how my states > controller > >>>>>>>> is > >> > >>>>>>>> > --------------------------------------------------------------------------- > --------------------------------------------------------------------------- > ----------------------------------- > >> > >>>>>>>> class StatesController < ApplicationController > >>>>>>>> # GET /states > >>>>>>>> # GET /states.json > >>>>>>>> def index > >>>>>>>> @states = State.all > >> > >>>>>>>> respond_to do |format| > >>>>>>>> format.html # index.html.erb > >>>>>>>> format.json { render json: @states } > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # GET /states/1 > >>>>>>>> # GET /states/1.json > >>>>>>>> def show > >>>>>>>> @state = State.find(params[:id]) > >> > >>>>>>>> respond_to do |format| > >>>>>>>> format.html # show.html.erb > >>>>>>>> format.json { render json: @state } > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # GET /states/new > >>>>>>>> # GET /states/new.json > >>>>>>>> def new > >>>>>>>> @state = State.new > >>>>>>>> respond_to do |format| > >>>>>>>> format.html # new.html.erb > >>>>>>>> format.json { render json: @state } > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # GET /states/1/edit > >>>>>>>> def edit > >>>>>>>> @state = State.find(params[:id]) > >>>>>>>> end > >> > >>>>>>>> # POST /states > >>>>>>>> # POST /states.json > >>>>>>>> def create > >>>>>>>> @state = State.new(params[:state]) > >> > >>>>>>>> respond_to do |format| > >>>>>>>> if @state.save > >>>>>>>> format.html { redirect_to @state, notice: ''State was > >>>>>>>> successfully created.'' } > >>>>>>>> format.json { render json: @state, status: :created, > >>>>>>>> location: @state } > >>>>>>>> else > >>>>>>>> format.html { render action: "new" } > >>>>>>>> format.json { render json: @state.errors, status: > >>>>>>>> :unprocessable_entity } > >>>>>>>> end > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> def countries_state > >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => > params[:country]}) > >>>>>>>> respond_to do |format| > >>>>>>>> format.html > >>>>>>>> format.js > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # PUT /states/1 > >>>>>>>> # PUT /states/1.json > >>>>>>>> def update > >>>>>>>> @state = State.find(params[:id]) > >> > >>>>>>>> respond_to do |format| > >>>>>>>> if @state.update_attributes(params[:state]) > >>>>>>>> format.html { redirect_to @state, notice: ''State was > >>>>>>>> successfully updated.'' } > >>>>>>>> format.json { head :ok } > >>>>>>>> else > >>>>>>>> format.html { render action: "edit" } > >>>>>>>> format.json { render json: @state.errors, status: > >>>>>>>> :unprocessable_entity } > >>>>>>>> end > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # DELETE /states/1 > >>>>>>>> # DELETE /states/1.json > >>>>>>>> def destroy > >>>>>>>> @state = State.find(params[:id]) > >>>>>>>> @state.destroy > >> > >>>>>>>> respond_to do |format| > >>>>>>>> format.html { redirect_to states_url } > >>>>>>>> format.json { head :ok } > >>>>>>>> end > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> > --------------------------------------------------------------------------- > --------------------------------------------------------------------------- > ------------------------------------ > >> > >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < > >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>> Make sure ur using the currect URL for the new action. > >> > >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < > >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>> Yea it looks like this... > >> > >>>>>>>>>> match "/states/countries_state/:country_id" => > >>>>>>>>>> "states#countries_state" > >> > >>>>>>>>>> resources :clients > >> > >>>>>>>>>> resources :skill_sets > >> > >>>>>>>>>> resources :technologies > >> > >>>>>>>>>> resources :level_of_contacts > >> > >>>>>>>>>> resources :states > >> > >>>>>>>>>> resources :discounts > >> > >>>>>>>>>> resources :countries > >> > >>>>>>>>>> resources :roles > >> > >>>>>>>>>> get "home/index" > >> > >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < > >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>> Make sure this route comes before the route entry for the > country > >>>>>>>>>>> resource. > >> > >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < > >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>> Yes i have added....it looks like this > >> > >>>>>>>>>>>> match "/states/countries_state/:country_id" => > >>>>>>>>>>>> "states#countries_state" > >> > >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < > >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>> Did you add a route for this new action? > >> > >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < > >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action > and > >>>>>>>>>>>>>> in states controller, and in application.js i have modified > the path like > >>>>>>>>>>>>>> this > >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; > however > >>>>>>>>>>>>>> on console its giving me eroor like > >>>>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... > Iam > >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new to > all > >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... > >> > >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < > >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>>> Hey AJ > >> > >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you would > need > >>>>>>>>>>>>>>> something on the server to handle the request. > >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple > thing > >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find something > quite easily. > >> > >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < > >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>>>> Hey Aziz, > >> > >>>>>>>>>>>>>>>> really thanks for you repl..........so do i need to > >>>>>>>>>>>>>>>> write a controller action that would return me the states > depending on the > >>>>>>>>>>>>>>>> country and how do i render the state drop down in Cilent > Form...Thanks.... > >> > >>>>>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>>>>> AJ > >> > >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < > >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>>>>> Hey AJ > >> > >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the > selected > >>>>>>>>>>>>>>>>> state if you are using a nested resource url structure. > >>>>>>>>>>>>>>>>> Your js would looks something like this: > >> > >>>>>>>>>>>>>>>>> $(document).ready(function() { > >>>>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; > >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { > >> > >> ... > >> > >> read more » > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On 3 May 2012, at 14:24, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes i have a Select box with this id = "client_state_id" .. when i run $("#client_state_id") the select drop down control gets highlighted. ThanksTry using replaceWith() instead of html() in your success function.> > On Thu, May 3, 2012 at 6:46 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello All, > > > > ill just summarize everything in this message..kindly suggest as to > > what might be wrong > > Do you have a div with the id of "client_state_id"? What do you get if you run $("#client_state_id") in firebug? > > Jeremy Walker > > > > > > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Iam trying to achiev a functionlity of state drop down > > been populated on click of country........i have achieved almost 90% > > of this......iam getting appropriate responce in my firebug. responce > > is like this when i click india..... > > > > <select id="states_state_id" name="states[state_id]"><option > > value="2">Goa</option></select> > > > > > > my application .js looks like this > > > > $(document).ready(function() { > > var country_states_path = ''/states/countries_state/''; > > $("#client_country_id").change(function() { > > var country_id = $(this).val(); > > $.ajax({ > > type: "GET", > > data: {country: country_id}, > > url: country_states_path+country_id, > > success: function(data) { > > $("#client_state_id").html(data) > > } > > }); > > }); > > }); > > > > > > > > the controller state has an action like this > > > > def countries_state > > @state = State.where("country_id = :c_id",{:c_id => > > params[:country_id]}) > > respond_to do |format| > > format.js > > end > > end > > > > > > > > and template for this action is like > > > > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) %> > > > > > > However i am getting the response in firebug but the html on page is > > not updated. Iam trying to find but iam stuck as iam a bit new to all > > this. > > > > > > Please suggest as to what might be wrong. thanks a lot > > > > > > Thanks & Regards, > > Akshar > > > > > > > > > > > > > > > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > > > > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> Hi all, > >> > >> I have succesfully got a responce like this as to what i want , this is the > >> ouptut in my fireofx console. > >> > >> <select id="states_state_id" name="states[state_id]"><option > >> value="1">Maharashtra</option></select>. > >> > >> but the html on the page is not updating.......any reson why this could be > >> ...thanks a lot.... > >> > >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < > >> > >> > >> > >> > >> > >> > >> > >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>> Also in the def countries_state > >>> @state = State.where("country_id = :c_id",{:c_id => params[:country_id]}) > >>> respond_to do |format| > >>> format.html > >>> end > >>> end > >> > >>> previously the it was format.js when nothing on the page was changing > >>> dynamically but when i make it format.html, the state drop down changes but > >>> i get all the unnecessary thing like the the entire html page. > >> > >>> Thanks > >> > >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < > >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>> Hi Aziz.... > >> > >>>> Iam getting whatevr reponce iam nneding,....... Thansk a lot.....in > >>>> the console in firbug when i see i get the states for a specific > >>>> counytry.....The responce is like "[["Goa", 2]]" .... however > >>>> whatever processing i do in application.js in not taking effect,,,,,, > >> > >>>> My application.js is > >> > >>>> $(document).ready(function() { > >>>> var country_states_path = ''/states/countries_state/''; > >>>> $("#client_country_id").change(function() { > >>>> var country_id = $(this).val(); > >>>> $.ajax({ > >>>> type: "GET", > >>>> data: {country: country_id}, > >>>> url: country_states_path+country_id, > >>>> success: function(data) { > >>>> $("#client_country_id").html(data) > >>>> } > >>>> }); > >>>> }); > >>>> }); > >> > >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala <aziz.bookw...@gmail.com>wrote: > >> > >>>>> Not a problem. > >> > >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < > >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help > >> > >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala <aziz.bookw...@gmail.com>wrote: > >> > >>>>>>> That is fine, though you could make it more ''RESTful'' by adding it as > >>>>>>> a nested resource. You can read about that here<http://railscasts.com/episodes/139-nested-resources>. > >>>>>>> The RailsCast is a little old, but you should get the idea. > >> > >>>>>>> With respect to your current problem, what is the url you are using in > >>>>>>> your js? > >> > >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < > >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>> Iam sorry i didnt get you.......... i have created a new action for > >>>>>>>> the ajax stuff is this approach wrong..... This is how my states controller > >>>>>>>> is > >> > >>>>>>>> --------------------------------------------------------------------------- --------------------------------------------------------------------------- ----------------------------------- > >> > >>>>>>>> class StatesController < ApplicationController > >>>>>>>> # GET /states > >>>>>>>> # GET /states.json > >>>>>>>> def index > >>>>>>>> @states = State.all > >> > >>>>>>>> respond_to do |format| > >>>>>>>> format.html # index.html.erb > >>>>>>>> format.json { render json: @states } > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # GET /states/1 > >>>>>>>> # GET /states/1.json > >>>>>>>> def show > >>>>>>>> @state = State.find(params[:id]) > >> > >>>>>>>> respond_to do |format| > >>>>>>>> format.html # show.html.erb > >>>>>>>> format.json { render json: @state } > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # GET /states/new > >>>>>>>> # GET /states/new.json > >>>>>>>> def new > >>>>>>>> @state = State.new > >>>>>>>> respond_to do |format| > >>>>>>>> format.html # new.html.erb > >>>>>>>> format.json { render json: @state } > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # GET /states/1/edit > >>>>>>>> def edit > >>>>>>>> @state = State.find(params[:id]) > >>>>>>>> end > >> > >>>>>>>> # POST /states > >>>>>>>> # POST /states.json > >>>>>>>> def create > >>>>>>>> @state = State.new(params[:state]) > >> > >>>>>>>> respond_to do |format| > >>>>>>>> if @state.save > >>>>>>>> format.html { redirect_to @state, notice: ''State was > >>>>>>>> successfully created.'' } > >>>>>>>> format.json { render json: @state, status: :created, > >>>>>>>> location: @state } > >>>>>>>> else > >>>>>>>> format.html { render action: "new" } > >>>>>>>> format.json { render json: @state.errors, status: > >>>>>>>> :unprocessable_entity } > >>>>>>>> end > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> def countries_state > >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => params[:country]}) > >>>>>>>> respond_to do |format| > >>>>>>>> format.html > >>>>>>>> format.js > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # PUT /states/1 > >>>>>>>> # PUT /states/1.json > >>>>>>>> def update > >>>>>>>> @state = State.find(params[:id]) > >> > >>>>>>>> respond_to do |format| > >>>>>>>> if @state.update_attributes(params[:state]) > >>>>>>>> format.html { redirect_to @state, notice: ''State was > >>>>>>>> successfully updated.'' } > >>>>>>>> format.json { head :ok } > >>>>>>>> else > >>>>>>>> format.html { render action: "edit" } > >>>>>>>> format.json { render json: @state.errors, status: > >>>>>>>> :unprocessable_entity } > >>>>>>>> end > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> # DELETE /states/1 > >>>>>>>> # DELETE /states/1.json > >>>>>>>> def destroy > >>>>>>>> @state = State.find(params[:id]) > >>>>>>>> @state.destroy > >> > >>>>>>>> respond_to do |format| > >>>>>>>> format.html { redirect_to states_url } > >>>>>>>> format.json { head :ok } > >>>>>>>> end > >>>>>>>> end > >>>>>>>> end > >> > >>>>>>>> --------------------------------------------------------------------------- --------------------------------------------------------------------------- ------------------------------------ > >> > >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < > >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>> Make sure ur using the currect URL for the new action. > >> > >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < > >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>> Yea it looks like this... > >> > >>>>>>>>>> match "/states/countries_state/:country_id" => > >>>>>>>>>> "states#countries_state" > >> > >>>>>>>>>> resources :clients > >> > >>>>>>>>>> resources :skill_sets > >> > >>>>>>>>>> resources :technologies > >> > >>>>>>>>>> resources :level_of_contacts > >> > >>>>>>>>>> resources :states > >> > >>>>>>>>>> resources :discounts > >> > >>>>>>>>>> resources :countries > >> > >>>>>>>>>> resources :roles > >> > >>>>>>>>>> get "home/index" > >> > >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < > >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>> Make sure this route comes before the route entry for the country > >>>>>>>>>>> resource. > >> > >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < > >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>> Yes i have added....it looks like this > >> > >>>>>>>>>>>> match "/states/countries_state/:country_id" => > >>>>>>>>>>>> "states#countries_state" > >> > >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < > >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>> Did you add a route for this new action? > >> > >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < > >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action and > >>>>>>>>>>>>>> in states controller, and in application.js i have modified the path like > >>>>>>>>>>>>>> this > >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; however > >>>>>>>>>>>>>> on console its giving me eroor like > >>>>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> ... Iam > >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new to all > >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... > >> > >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < > >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>>> Hey AJ > >> > >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you would need > >>>>>>>>>>>>>>> something on the server to handle the request. > >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple thing > >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find something quite easily. > >> > >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < > >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>>>> Hey Aziz, > >> > >>>>>>>>>>>>>>>> really thanks for you repl..........so do i need to > >>>>>>>>>>>>>>>> write a controller action that would return me the states depending on the > >>>>>>>>>>>>>>>> country and how do i render the state drop down in Cilent Form...Thanks.... > >> > >>>>>>>>>>>>>>>> Thanks, > >>>>>>>>>>>>>>>> AJ > >> > >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < > >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >>>>>>>>>>>>>>>>> Hey AJ > >> > >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the selected > >>>>>>>>>>>>>>>>> state if you are using a nested resource url structure. > >>>>>>>>>>>>>>>>> Your js would looks something like this: > >> > >>>>>>>>>>>>>>>>> $(document).ready(function() { > >>>>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; > >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { > >> > >> ... > >> > >> read more » > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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. > > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
HEy cool.. Thanks a lot...it worked however with state drop down i also iam getting a lot of other un necessary html...... The html is what i have written in application.html.erb for templating purpose....... Is this the wrong way to write static html code in application.html.erb... Thanks a lot.... On Thu, May 3, 2012 at 7:02 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 3 May 2012, at 14:24, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Yes i have a Select box with this id = "client_state_id" .. when i run > $("#client_state_id") the select drop down control gets highlighted. Thanks > > > Try using replaceWith() instead of html() in your success function. > > > On Thu, May 3, 2012 at 6:46 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> >> >> On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > Hello All, >> > >> > ill just summarize everything in this message..kindly suggest as to >> > what might be wrong >> >> Do you have a div with the id of "client_state_id"? What do you get if >> you run $("#client_state_id") in firebug? >> >> Jeremy Walker >> >> > >> > >> > >> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> > Iam trying to achiev a functionlity of state drop down >> > been populated on click of country........i have achieved almost 90% >> > of this......iam getting appropriate responce in my firebug. responce >> > is like this when i click india..... >> > >> > <select id="states_state_id" name="states[state_id]"><option >> > value="2">Goa</option></select> >> > >> > >> > my application .js looks like this >> > >> > $(document).ready(function() { >> > var country_states_path = ''/states/countries_state/''; >> > $("#client_country_id").change(function() { >> > var country_id = $(this).val(); >> > $.ajax({ >> > type: "GET", >> > data: {country: country_id}, >> > url: country_states_path+country_id, >> > success: function(data) { >> > $("#client_state_id").html(data) >> > } >> > }); >> > }); >> > }); >> > >> > >> > >> > the controller state has an action like this >> > >> > def countries_state >> > @state = State.where("country_id = :c_id",{:c_id => >> > params[:country_id]}) >> > respond_to do |format| >> > format.js >> > end >> > end >> > >> > >> > >> > and template for this action is like >> > >> > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) %> >> > >> > >> > However i am getting the response in firebug but the html on page is >> > not updated. Iam trying to find but iam stuck as iam a bit new to all >> > this. >> > >> > >> > Please suggest as to what might be wrong. thanks a lot >> > >> > >> > Thanks & Regards, >> > Akshar >> > >> > >> > >> > >> > >> > >> > >> > >> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >> > >> > >> > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> > wrote: >> >> Hi all, >> >> >> >> I have succesfully got a responce like this as to what i want , this >> is the >> >> ouptut in my fireofx console. >> >> >> >> <select id="states_state_id" name="states[state_id]"><option >> >> value="1">Maharashtra</option></select>. >> >> >> >> but the html on the page is not updating.......any reson why this >> could be >> >> ...thanks a lot.... >> >> >> >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Also in the def countries_state >> >>> @state = State.where("country_id = :c_id",{:c_id => >> params[:country_id]}) >> >>> respond_to do |format| >> >>> format.html >> >>> end >> >>> end >> >> >> >>> previously the it was format.js when nothing on the page was changing >> >>> dynamically but when i make it format.html, the state drop down >> changes but >> >>> i get all the unnecessary thing like the the entire html page. >> >> >> >>> Thanks >> >> >> >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < >> >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>> Hi Aziz.... >> >> >> >>>> Iam getting whatevr reponce iam nneding,....... Thansk a >> lot.....in >> >>>> the console in firbug when i see i get the states for a specific >> >>>> counytry.....The responce is like "[["Goa", 2]]" .... >> however >> >>>> whatever processing i do in application.js in not taking effect,,,,,, >> >> >> >>>> My application.js is >> >> >> >>>> $(document).ready(function() { >> >>>> var country_states_path = ''/states/countries_state/''; >> >>>> $("#client_country_id").change(function() { >> >>>> var country_id = $(this).val(); >> >>>> $.ajax({ >> >>>> type: "GET", >> >>>> data: {country: country_id}, >> >>>> url: country_states_path+country_id, >> >>>> success: function(data) { >> >>>> $("#client_country_id").html(data) >> >>>> } >> >>>> }); >> >>>> }); >> >>>> }); >> >> >> >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala < >> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >> >> >>>>> Not a problem. >> >> >> >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >> >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help >> >> >> >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala < >> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >> >> >>>>>>> That is fine, though you could make it more ''RESTful'' by adding >> it as >> >>>>>>> a nested resource. You can read about that here< >> http://railscasts.com/episodes/139-nested-resources>. >> >>>>>>> The RailsCast is a little old, but you should get the idea. >> >> >> >>>>>>> With respect to your current problem, what is the url you are >> using in >> >>>>>>> your js? >> >> >> >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >> >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>> Iam sorry i didnt get you.......... i have created a new action >> for >> >>>>>>>> the ajax stuff is this approach wrong..... This is how my states >> controller >> >>>>>>>> is >> >> >> >>>>>>>> >> --------------------------------------------------------------------------- >> --------------------------------------------------------------------------- >> ----------------------------------- >> >> >> >>>>>>>> class StatesController < ApplicationController >> >>>>>>>> # GET /states >> >>>>>>>> # GET /states.json >> >>>>>>>> def index >> >>>>>>>> @states = State.all >> >> >> >>>>>>>> respond_to do |format| >> >>>>>>>> format.html # index.html.erb >> >>>>>>>> format.json { render json: @states } >> >>>>>>>> end >> >>>>>>>> end >> >> >> >>>>>>>> # GET /states/1 >> >>>>>>>> # GET /states/1.json >> >>>>>>>> def show >> >>>>>>>> @state = State.find(params[:id]) >> >> >> >>>>>>>> respond_to do |format| >> >>>>>>>> format.html # show.html.erb >> >>>>>>>> format.json { render json: @state } >> >>>>>>>> end >> >>>>>>>> end >> >> >> >>>>>>>> # GET /states/new >> >>>>>>>> # GET /states/new.json >> >>>>>>>> def new >> >>>>>>>> @state = State.new >> >>>>>>>> respond_to do |format| >> >>>>>>>> format.html # new.html.erb >> >>>>>>>> format.json { render json: @state } >> >>>>>>>> end >> >>>>>>>> end >> >> >> >>>>>>>> # GET /states/1/edit >> >>>>>>>> def edit >> >>>>>>>> @state = State.find(params[:id]) >> >>>>>>>> end >> >> >> >>>>>>>> # POST /states >> >>>>>>>> # POST /states.json >> >>>>>>>> def create >> >>>>>>>> @state = State.new(params[:state]) >> >> >> >>>>>>>> respond_to do |format| >> >>>>>>>> if @state.save >> >>>>>>>> format.html { redirect_to @state, notice: ''State was >> >>>>>>>> successfully created.'' } >> >>>>>>>> format.json { render json: @state, status: :created, >> >>>>>>>> location: @state } >> >>>>>>>> else >> >>>>>>>> format.html { render action: "new" } >> >>>>>>>> format.json { render json: @state.errors, status: >> >>>>>>>> :unprocessable_entity } >> >>>>>>>> end >> >>>>>>>> end >> >>>>>>>> end >> >> >> >>>>>>>> def countries_state >> >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => >> params[:country]}) >> >>>>>>>> respond_to do |format| >> >>>>>>>> format.html >> >>>>>>>> format.js >> >>>>>>>> end >> >>>>>>>> end >> >> >> >>>>>>>> # PUT /states/1 >> >>>>>>>> # PUT /states/1.json >> >>>>>>>> def update >> >>>>>>>> @state = State.find(params[:id]) >> >> >> >>>>>>>> respond_to do |format| >> >>>>>>>> if @state.update_attributes(params[:state]) >> >>>>>>>> format.html { redirect_to @state, notice: ''State was >> >>>>>>>> successfully updated.'' } >> >>>>>>>> format.json { head :ok } >> >>>>>>>> else >> >>>>>>>> format.html { render action: "edit" } >> >>>>>>>> format.json { render json: @state.errors, status: >> >>>>>>>> :unprocessable_entity } >> >>>>>>>> end >> >>>>>>>> end >> >>>>>>>> end >> >> >> >>>>>>>> # DELETE /states/1 >> >>>>>>>> # DELETE /states/1.json >> >>>>>>>> def destroy >> >>>>>>>> @state = State.find(params[:id]) >> >>>>>>>> @state.destroy >> >> >> >>>>>>>> respond_to do |format| >> >>>>>>>> format.html { redirect_to states_url } >> >>>>>>>> format.json { head :ok } >> >>>>>>>> end >> >>>>>>>> end >> >>>>>>>> end >> >> >> >>>>>>>> >> --------------------------------------------------------------------------- >> --------------------------------------------------------------------------- >> ------------------------------------ >> >> >> >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < >> >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>> Make sure ur using the currect URL for the new action. >> >> >> >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >> >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>> Yea it looks like this... >> >> >> >>>>>>>>>> match "/states/countries_state/:country_id" => >> >>>>>>>>>> "states#countries_state" >> >> >> >>>>>>>>>> resources :clients >> >> >> >>>>>>>>>> resources :skill_sets >> >> >> >>>>>>>>>> resources :technologies >> >> >> >>>>>>>>>> resources :level_of_contacts >> >> >> >>>>>>>>>> resources :states >> >> >> >>>>>>>>>> resources :discounts >> >> >> >>>>>>>>>> resources :countries >> >> >> >>>>>>>>>> resources :roles >> >> >> >>>>>>>>>> get "home/index" >> >> >> >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >> >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>>> Make sure this route comes before the route entry for the >> country >> >>>>>>>>>>> resource. >> >> >> >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >> >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>>>> Yes i have added....it looks like this >> >> >> >>>>>>>>>>>> match "/states/countries_state/:country_id" => >> >>>>>>>>>>>> "states#countries_state" >> >> >> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >> >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>>>>> Did you add a route for this new action? >> >> >> >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >> >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state action >> and >> >>>>>>>>>>>>>> in states controller, and in application.js i have >> modified the path like >> >>>>>>>>>>>>>> this >> >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; >> however >> >>>>>>>>>>>>>> on console its giving me eroor like >> >>>>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> >> ... Iam >> >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new to >> all >> >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... >> >> >> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >> >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>>>>>>> Hey AJ >> >> >> >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you would >> need >> >>>>>>>>>>>>>>> something on the server to handle the request. >> >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple >> thing >> >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find something >> quite easily. >> >> >> >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >> >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>>>>>>>> Hey Aziz, >> >> >> >>>>>>>>>>>>>>>> really thanks for you repl..........so do i need >> to >> >>>>>>>>>>>>>>>> write a controller action that would return me the >> states depending on the >> >>>>>>>>>>>>>>>> country and how do i render the state drop down in >> Cilent Form...Thanks.... >> >> >> >>>>>>>>>>>>>>>> Thanks, >> >>>>>>>>>>>>>>>> AJ >> >> >> >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >> >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >>>>>>>>>>>>>>>>> Hey AJ >> >> >> >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the >> selected >> >>>>>>>>>>>>>>>>> state if you are using a nested resource url structure. >> >>>>>>>>>>>>>>>>> Your js would looks something like this: >> >> >> >>>>>>>>>>>>>>>>> $(document).ready(function() { >> >>>>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >> >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { >> >> >> >> ... >> >> >> >> read more » >> > >> > -- >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > >> >> >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On 3 May 2012 14:38, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> HEy cool.. Thanks a lot...it worked however with state drop down i also > iam getting a lot of other un necessary html...... The html is what i have > written in application.html.erb for templating purpose....... Is this the > wrong way to write static html code in application.html.erb... Thanks a > lot....You need to tell your view not render the layout. You should read the Rails guide to rendering and layouts. I''ll let you figure it out from there: http://guides.rubyonrails.org/layouts_and_rendering.html Just for your reference, I feel that a better way of achieving what you''re doing would be: * Have nested routes for countries and states and call the url at /countries/1/states.json ( http://guides.rubyonrails.org/routing.html#nested-resources) * Have the index method of the StatesController respond to the .json request and render the states back as a JSON array. Let the browser and create the <option> tags using Javascript. IMHO that way is quicker, slicker and more maintainable. Also, in your current form, you could replace your $.ajax method with: $.get(country_states_path+country_id, function(data) { $("#client_state_id").replaceWith(data); } }); Hope that''s helpful.> On Thu, May 3, 2012 at 7:02 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> >> >> On 3 May 2012, at 14:24, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >> Yes i have a Select box with this id = "client_state_id" .. when i run >> $("#client_state_id") the select drop down control gets highlighted. Thanks >> >> >> Try using replaceWith() instead of html() in your success function. >> >> >> On Thu, May 3, 2012 at 6:46 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> >>> >>> On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> > Hello All, >>> > >>> > ill just summarize everything in this message..kindly suggest as to >>> > what might be wrong >>> >>> Do you have a div with the id of "client_state_id"? What do you get if >>> you run $("#client_state_id") in firebug? >>> >>> Jeremy Walker >>> >>> > >>> > >>> > >>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>> > Iam trying to achiev a functionlity of state drop down >>> > been populated on click of country........i have achieved almost 90% >>> > of this......iam getting appropriate responce in my firebug. responce >>> > is like this when i click india..... >>> > >>> > <select id="states_state_id" name="states[state_id]"><option >>> > value="2">Goa</option></select> >>> > >>> > >>> > my application .js looks like this >>> > >>> > $(document).ready(function() { >>> > var country_states_path = ''/states/countries_state/''; >>> > $("#client_country_id").change(function() { >>> > var country_id = $(this).val(); >>> > $.ajax({ >>> > type: "GET", >>> > data: {country: country_id}, >>> > url: country_states_path+country_id, >>> > success: function(data) { >>> > $("#client_state_id").html(data) >>> > } >>> > }); >>> > }); >>> > }); >>> > >>> > >>> > >>> > the controller state has an action like this >>> > >>> > def countries_state >>> > @state = State.where("country_id = :c_id",{:c_id => >>> > params[:country_id]}) >>> > respond_to do |format| >>> > format.js >>> > end >>> > end >>> > >>> > >>> > >>> > and template for this action is like >>> > >>> > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) %> >>> > >>> > >>> > However i am getting the response in firebug but the html on page is >>> > not updated. Iam trying to find but iam stuck as iam a bit new to all >>> > this. >>> > >>> > >>> > Please suggest as to what might be wrong. thanks a lot >>> > >>> > >>> > Thanks & Regards, >>> > Akshar >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>> > >>> > >>> > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> > wrote: >>> >> Hi all, >>> >> >>> >> I have succesfully got a responce like this as to what i want , this >>> is the >>> >> ouptut in my fireofx console. >>> >> >>> >> <select id="states_state_id" name="states[state_id]"><option >>> >> value="1">Maharashtra</option></select>. >>> >> >>> >> but the html on the page is not updating.......any reson why this >>> could be >>> >> ...thanks a lot.... >>> >> >>> >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> Also in the def countries_state >>> >>> @state = State.where("country_id = :c_id",{:c_id => >>> params[:country_id]}) >>> >>> respond_to do |format| >>> >>> format.html >>> >>> end >>> >>> end >>> >> >>> >>> previously the it was format.js when nothing on the page was changing >>> >>> dynamically but when i make it format.html, the state drop down >>> changes but >>> >>> i get all the unnecessary thing like the the entire html page. >>> >> >>> >>> Thanks >>> >> >>> >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < >>> >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>> Hi Aziz.... >>> >> >>> >>>> Iam getting whatevr reponce iam nneding,....... Thansk a >>> lot.....in >>> >>>> the console in firbug when i see i get the states for a specific >>> >>>> counytry.....The responce is like "[["Goa", 2]]" .... >>> however >>> >>>> whatever processing i do in application.js in not taking >>> effect,,,,,, >>> >> >>> >>>> My application.js is >>> >> >>> >>>> $(document).ready(function() { >>> >>>> var country_states_path = ''/states/countries_state/''; >>> >>>> $("#client_country_id").change(function() { >>> >>>> var country_id = $(this).val(); >>> >>>> $.ajax({ >>> >>>> type: "GET", >>> >>>> data: {country: country_id}, >>> >>>> url: country_states_path+country_id, >>> >>>> success: function(data) { >>> >>>> $("#client_country_id").html(data) >>> >>>> } >>> >>>> }); >>> >>>> }); >>> >>>> }); >>> >> >>> >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala < >>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >> >>> >>>>> Not a problem. >>> >> >>> >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >>> >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help >>> >> >>> >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala < >>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >> >>> >>>>>>> That is fine, though you could make it more ''RESTful'' by adding >>> it as >>> >>>>>>> a nested resource. You can read about that here< >>> http://railscasts.com/episodes/139-nested-resources>. >>> >>>>>>> The RailsCast is a little old, but you should get the idea. >>> >> >>> >>>>>>> With respect to your current problem, what is the url you are >>> using in >>> >>>>>>> your js? >>> >> >>> >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>> >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>> Iam sorry i didnt get you.......... i have created a new action >>> for >>> >>>>>>>> the ajax stuff is this approach wrong..... This is how my >>> states controller >>> >>>>>>>> is >>> >> >>> >>>>>>>> >>> --------------------------------------------------------------------------- >>> --------------------------------------------------------------------------- >>> ----------------------------------- >>> >> >>> >>>>>>>> class StatesController < ApplicationController >>> >>>>>>>> # GET /states >>> >>>>>>>> # GET /states.json >>> >>>>>>>> def index >>> >>>>>>>> @states = State.all >>> >> >>> >>>>>>>> respond_to do |format| >>> >>>>>>>> format.html # index.html.erb >>> >>>>>>>> format.json { render json: @states } >>> >>>>>>>> end >>> >>>>>>>> end >>> >> >>> >>>>>>>> # GET /states/1 >>> >>>>>>>> # GET /states/1.json >>> >>>>>>>> def show >>> >>>>>>>> @state = State.find(params[:id]) >>> >> >>> >>>>>>>> respond_to do |format| >>> >>>>>>>> format.html # show.html.erb >>> >>>>>>>> format.json { render json: @state } >>> >>>>>>>> end >>> >>>>>>>> end >>> >> >>> >>>>>>>> # GET /states/new >>> >>>>>>>> # GET /states/new.json >>> >>>>>>>> def new >>> >>>>>>>> @state = State.new >>> >>>>>>>> respond_to do |format| >>> >>>>>>>> format.html # new.html.erb >>> >>>>>>>> format.json { render json: @state } >>> >>>>>>>> end >>> >>>>>>>> end >>> >> >>> >>>>>>>> # GET /states/1/edit >>> >>>>>>>> def edit >>> >>>>>>>> @state = State.find(params[:id]) >>> >>>>>>>> end >>> >> >>> >>>>>>>> # POST /states >>> >>>>>>>> # POST /states.json >>> >>>>>>>> def create >>> >>>>>>>> @state = State.new(params[:state]) >>> >> >>> >>>>>>>> respond_to do |format| >>> >>>>>>>> if @state.save >>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>> >>>>>>>> successfully created.'' } >>> >>>>>>>> format.json { render json: @state, status: :created, >>> >>>>>>>> location: @state } >>> >>>>>>>> else >>> >>>>>>>> format.html { render action: "new" } >>> >>>>>>>> format.json { render json: @state.errors, status: >>> >>>>>>>> :unprocessable_entity } >>> >>>>>>>> end >>> >>>>>>>> end >>> >>>>>>>> end >>> >> >>> >>>>>>>> def countries_state >>> >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => >>> params[:country]}) >>> >>>>>>>> respond_to do |format| >>> >>>>>>>> format.html >>> >>>>>>>> format.js >>> >>>>>>>> end >>> >>>>>>>> end >>> >> >>> >>>>>>>> # PUT /states/1 >>> >>>>>>>> # PUT /states/1.json >>> >>>>>>>> def update >>> >>>>>>>> @state = State.find(params[:id]) >>> >> >>> >>>>>>>> respond_to do |format| >>> >>>>>>>> if @state.update_attributes(params[:state]) >>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>> >>>>>>>> successfully updated.'' } >>> >>>>>>>> format.json { head :ok } >>> >>>>>>>> else >>> >>>>>>>> format.html { render action: "edit" } >>> >>>>>>>> format.json { render json: @state.errors, status: >>> >>>>>>>> :unprocessable_entity } >>> >>>>>>>> end >>> >>>>>>>> end >>> >>>>>>>> end >>> >> >>> >>>>>>>> # DELETE /states/1 >>> >>>>>>>> # DELETE /states/1.json >>> >>>>>>>> def destroy >>> >>>>>>>> @state = State.find(params[:id]) >>> >>>>>>>> @state.destroy >>> >> >>> >>>>>>>> respond_to do |format| >>> >>>>>>>> format.html { redirect_to states_url } >>> >>>>>>>> format.json { head :ok } >>> >>>>>>>> end >>> >>>>>>>> end >>> >>>>>>>> end >>> >> >>> >>>>>>>> >>> --------------------------------------------------------------------------- >>> --------------------------------------------------------------------------- >>> ------------------------------------ >>> >> >>> >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < >>> >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>> Make sure ur using the currect URL for the new action. >>> >> >>> >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>> >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>> Yea it looks like this... >>> >> >>> >>>>>>>>>> match "/states/countries_state/:country_id" => >>> >>>>>>>>>> "states#countries_state" >>> >> >>> >>>>>>>>>> resources :clients >>> >> >>> >>>>>>>>>> resources :skill_sets >>> >> >>> >>>>>>>>>> resources :technologies >>> >> >>> >>>>>>>>>> resources :level_of_contacts >>> >> >>> >>>>>>>>>> resources :states >>> >> >>> >>>>>>>>>> resources :discounts >>> >> >>> >>>>>>>>>> resources :countries >>> >> >>> >>>>>>>>>> resources :roles >>> >> >>> >>>>>>>>>> get "home/index" >>> >> >>> >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>> >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>>> Make sure this route comes before the route entry for the >>> country >>> >>>>>>>>>>> resource. >>> >> >>> >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>> >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>>>> Yes i have added....it looks like this >>> >> >>> >>>>>>>>>>>> match "/states/countries_state/:country_id" => >>> >>>>>>>>>>>> "states#countries_state" >>> >> >>> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>> >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>>>>> Did you add a route for this new action? >>> >> >>> >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>> >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state >>> action and >>> >>>>>>>>>>>>>> in states controller, and in application.js i have >>> modified the path like >>> >>>>>>>>>>>>>> this >>> >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; >>> however >>> >>>>>>>>>>>>>> on console its giving me eroor like >>> >>>>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> >>> ... Iam >>> >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new >>> to all >>> >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... >>> >> >>> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>> >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>>>>>>> Hey AJ >>> >> >>> >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you would >>> need >>> >>>>>>>>>>>>>>> something on the server to handle the request. >>> >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple >>> thing >>> >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find >>> something quite easily. >>> >> >>> >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>> >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>>>>>>>> Hey Aziz, >>> >> >>> >>>>>>>>>>>>>>>> really thanks for you repl..........so do i need >>> to >>> >>>>>>>>>>>>>>>> write a controller action that would return me the >>> states depending on the >>> >>>>>>>>>>>>>>>> country and how do i render the state drop down in >>> Cilent Form...Thanks.... >>> >> >>> >>>>>>>>>>>>>>>> Thanks, >>> >>>>>>>>>>>>>>>> AJ >>> >> >>> >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>> >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >> >>> >>>>>>>>>>>>>>>>> Hey AJ >>> >> >>> >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the >>> selected >>> >>>>>>>>>>>>>>>>> state if you are using a nested resource url structure. >>> >>>>>>>>>>>>>>>>> Your js would looks something like this: >>> >> >>> >>>>>>>>>>>>>>>>> $(document).ready(function() { >>> >>>>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>> >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>> >> >>> >> ... >>> >> >>> >> read more » >>> > >>> > -- >>> > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >>> . >>> > To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> > For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> > >>> >>> >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >>> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Hey Guys... All of You... Thanks alot...... i have achieved it........i was struglling on it from 2 3 days....and without all of your help i wouldnt have successeded...... RUBY ON RAILS ROCK....thanks On Thu, May 3, 2012 at 7:31 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 3 May 2012 14:38, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> HEy cool.. Thanks a lot...it worked however with state drop down i also >> iam getting a lot of other un necessary html...... The html is what i have >> written in application.html.erb for templating purpose....... Is this the >> wrong way to write static html code in application.html.erb... Thanks a >> lot.... > > > You need to tell your view not render the layout. You should read the > Rails guide to rendering and layouts. I''ll let you figure it out from there: > http://guides.rubyonrails.org/layouts_and_rendering.html > > Just for your reference, I feel that a better way of achieving what you''re > doing would be: > * Have nested routes for countries and states and call the url at > /countries/1/states.json ( > http://guides.rubyonrails.org/routing.html#nested-resources) > * Have the index method of the StatesController respond to the .json > request and render the states back as a JSON array. Let the browser and > create the <option> tags using Javascript. > > IMHO that way is quicker, slicker and more maintainable. > > Also, in your current form, you could replace your $.ajax method with: > > $.get(country_states_path+country_id, function(data) { > $("#client_state_id").replaceWith(data); > } > }); > > Hope that''s helpful. > > >> On Thu, May 3, 2012 at 7:02 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> >>> >>> On 3 May 2012, at 14:24, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> wrote: >>> >>> Yes i have a Select box with this id = "client_state_id" .. when i run >>> $("#client_state_id") the select drop down control gets highlighted. Thanks >>> >>> >>> Try using replaceWith() instead of html() in your success function. >>> >>> >>> On Thu, May 3, 2012 at 6:46 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> >>>> >>>> On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>> > Hello All, >>>> > >>>> > ill just summarize everything in this message..kindly suggest as to >>>> > what might be wrong >>>> >>>> Do you have a div with the id of "client_state_id"? What do you get if >>>> you run $("#client_state_id") in firebug? >>>> >>>> Jeremy Walker >>>> >>>> > >>>> > >>>> > >>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>> > Iam trying to achiev a functionlity of state drop down >>>> > been populated on click of country........i have achieved almost 90% >>>> > of this......iam getting appropriate responce in my firebug. responce >>>> > is like this when i click india..... >>>> > >>>> > <select id="states_state_id" name="states[state_id]"><option >>>> > value="2">Goa</option></select> >>>> > >>>> > >>>> > my application .js looks like this >>>> > >>>> > $(document).ready(function() { >>>> > var country_states_path = ''/states/countries_state/''; >>>> > $("#client_country_id").change(function() { >>>> > var country_id = $(this).val(); >>>> > $.ajax({ >>>> > type: "GET", >>>> > data: {country: country_id}, >>>> > url: country_states_path+country_id, >>>> > success: function(data) { >>>> > $("#client_state_id").html(data) >>>> > } >>>> > }); >>>> > }); >>>> > }); >>>> > >>>> > >>>> > >>>> > the controller state has an action like this >>>> > >>>> > def countries_state >>>> > @state = State.where("country_id = :c_id",{:c_id => >>>> > params[:country_id]}) >>>> > respond_to do |format| >>>> > format.js >>>> > end >>>> > end >>>> > >>>> > >>>> > >>>> > and template for this action is like >>>> > >>>> > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) >>>> %> >>>> > >>>> > >>>> > However i am getting the response in firebug but the html on page is >>>> > not updated. Iam trying to find but iam stuck as iam a bit new to all >>>> > this. >>>> > >>>> > >>>> > Please suggest as to what might be wrong. thanks a lot >>>> > >>>> > >>>> > Thanks & Regards, >>>> > Akshar >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>> > >>>> > >>>> > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>> > wrote: >>>> >> Hi all, >>>> >> >>>> >> I have succesfully got a responce like this as to what i want , this >>>> is the >>>> >> ouptut in my fireofx console. >>>> >> >>>> >> <select id="states_state_id" name="states[state_id]"><option >>>> >> value="1">Maharashtra</option></select>. >>>> >> >>>> >> but the html on the page is not updating.......any reson why this >>>> could be >>>> >> ...thanks a lot.... >>>> >> >>>> >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>> Also in the def countries_state >>>> >>> @state = State.where("country_id = :c_id",{:c_id => >>>> params[:country_id]}) >>>> >>> respond_to do |format| >>>> >>> format.html >>>> >>> end >>>> >>> end >>>> >> >>>> >>> previously the it was format.js when nothing on the page was >>>> changing >>>> >>> dynamically but when i make it format.html, the state drop down >>>> changes but >>>> >>> i get all the unnecessary thing like the the entire html page. >>>> >> >>>> >>> Thanks >>>> >> >>>> >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < >>>> >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>> Hi Aziz.... >>>> >> >>>> >>>> Iam getting whatevr reponce iam nneding,....... Thansk a >>>> lot.....in >>>> >>>> the console in firbug when i see i get the states for a specific >>>> >>>> counytry.....The responce is like "[["Goa", 2]]" .... >>>> however >>>> >>>> whatever processing i do in application.js in not taking >>>> effect,,,,,, >>>> >> >>>> >>>> My application.js is >>>> >> >>>> >>>> $(document).ready(function() { >>>> >>>> var country_states_path = ''/states/countries_state/''; >>>> >>>> $("#client_country_id").change(function() { >>>> >>>> var country_id = $(this).val(); >>>> >>>> $.ajax({ >>>> >>>> type: "GET", >>>> >>>> data: {country: country_id}, >>>> >>>> url: country_states_path+country_id, >>>> >>>> success: function(data) { >>>> >>>> $("#client_country_id").html(data) >>>> >>>> } >>>> >>>> }); >>>> >>>> }); >>>> >>>> }); >>>> >> >>>> >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala < >>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >> >>>> >>>>> Not a problem. >>>> >> >>>> >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >>>> >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help >>>> >> >>>> >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala < >>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >> >>>> >>>>>>> That is fine, though you could make it more ''RESTful'' by adding >>>> it as >>>> >>>>>>> a nested resource. You can read about that here< >>>> http://railscasts.com/episodes/139-nested-resources>. >>>> >>>>>>> The RailsCast is a little old, but you should get the idea. >>>> >> >>>> >>>>>>> With respect to your current problem, what is the url you are >>>> using in >>>> >>>>>>> your js? >>>> >> >>>> >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>>> >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>> Iam sorry i didnt get you.......... i have created a new >>>> action for >>>> >>>>>>>> the ajax stuff is this approach wrong..... This is how my >>>> states controller >>>> >>>>>>>> is >>>> >> >>>> >>>>>>>> >>>> --------------------------------------------------------------------------- >>>> --------------------------------------------------------------------------- >>>> ----------------------------------- >>>> >> >>>> >>>>>>>> class StatesController < ApplicationController >>>> >>>>>>>> # GET /states >>>> >>>>>>>> # GET /states.json >>>> >>>>>>>> def index >>>> >>>>>>>> @states = State.all >>>> >> >>>> >>>>>>>> respond_to do |format| >>>> >>>>>>>> format.html # index.html.erb >>>> >>>>>>>> format.json { render json: @states } >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> # GET /states/1 >>>> >>>>>>>> # GET /states/1.json >>>> >>>>>>>> def show >>>> >>>>>>>> @state = State.find(params[:id]) >>>> >> >>>> >>>>>>>> respond_to do |format| >>>> >>>>>>>> format.html # show.html.erb >>>> >>>>>>>> format.json { render json: @state } >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> # GET /states/new >>>> >>>>>>>> # GET /states/new.json >>>> >>>>>>>> def new >>>> >>>>>>>> @state = State.new >>>> >>>>>>>> respond_to do |format| >>>> >>>>>>>> format.html # new.html.erb >>>> >>>>>>>> format.json { render json: @state } >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> # GET /states/1/edit >>>> >>>>>>>> def edit >>>> >>>>>>>> @state = State.find(params[:id]) >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> # POST /states >>>> >>>>>>>> # POST /states.json >>>> >>>>>>>> def create >>>> >>>>>>>> @state = State.new(params[:state]) >>>> >> >>>> >>>>>>>> respond_to do |format| >>>> >>>>>>>> if @state.save >>>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>> >>>>>>>> successfully created.'' } >>>> >>>>>>>> format.json { render json: @state, status: :created, >>>> >>>>>>>> location: @state } >>>> >>>>>>>> else >>>> >>>>>>>> format.html { render action: "new" } >>>> >>>>>>>> format.json { render json: @state.errors, status: >>>> >>>>>>>> :unprocessable_entity } >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> def countries_state >>>> >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => >>>> params[:country]}) >>>> >>>>>>>> respond_to do |format| >>>> >>>>>>>> format.html >>>> >>>>>>>> format.js >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> # PUT /states/1 >>>> >>>>>>>> # PUT /states/1.json >>>> >>>>>>>> def update >>>> >>>>>>>> @state = State.find(params[:id]) >>>> >> >>>> >>>>>>>> respond_to do |format| >>>> >>>>>>>> if @state.update_attributes(params[:state]) >>>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>> >>>>>>>> successfully updated.'' } >>>> >>>>>>>> format.json { head :ok } >>>> >>>>>>>> else >>>> >>>>>>>> format.html { render action: "edit" } >>>> >>>>>>>> format.json { render json: @state.errors, status: >>>> >>>>>>>> :unprocessable_entity } >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> # DELETE /states/1 >>>> >>>>>>>> # DELETE /states/1.json >>>> >>>>>>>> def destroy >>>> >>>>>>>> @state = State.find(params[:id]) >>>> >>>>>>>> @state.destroy >>>> >> >>>> >>>>>>>> respond_to do |format| >>>> >>>>>>>> format.html { redirect_to states_url } >>>> >>>>>>>> format.json { head :ok } >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >>>>>>>> end >>>> >> >>>> >>>>>>>> >>>> --------------------------------------------------------------------------- >>>> --------------------------------------------------------------------------- >>>> ------------------------------------ >>>> >> >>>> >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < >>>> >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>> Make sure ur using the currect URL for the new action. >>>> >> >>>> >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>> >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>> Yea it looks like this... >>>> >> >>>> >>>>>>>>>> match "/states/countries_state/:country_id" => >>>> >>>>>>>>>> "states#countries_state" >>>> >> >>>> >>>>>>>>>> resources :clients >>>> >> >>>> >>>>>>>>>> resources :skill_sets >>>> >> >>>> >>>>>>>>>> resources :technologies >>>> >> >>>> >>>>>>>>>> resources :level_of_contacts >>>> >> >>>> >>>>>>>>>> resources :states >>>> >> >>>> >>>>>>>>>> resources :discounts >>>> >> >>>> >>>>>>>>>> resources :countries >>>> >> >>>> >>>>>>>>>> resources :roles >>>> >> >>>> >>>>>>>>>> get "home/index" >>>> >> >>>> >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>>> >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>>> Make sure this route comes before the route entry for the >>>> country >>>> >>>>>>>>>>> resource. >>>> >> >>>> >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>> >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>>>> Yes i have added....it looks like this >>>> >> >>>> >>>>>>>>>>>> match "/states/countries_state/:country_id" => >>>> >>>>>>>>>>>> "states#countries_state" >>>> >> >>>> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>> >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>>>>> Did you add a route for this new action? >>>> >> >>>> >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>> >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state >>>> action and >>>> >>>>>>>>>>>>>> in states controller, and in application.js i have >>>> modified the path like >>>> >>>>>>>>>>>>>> this >>>> >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; >>>> however >>>> >>>>>>>>>>>>>> on console its giving me eroor like >>>> >>>>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> >>>> ... Iam >>>> >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new >>>> to all >>>> >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... >>>> >> >>>> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>> >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>>>>>>> Hey AJ >>>> >> >>>> >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you >>>> would need >>>> >>>>>>>>>>>>>>> something on the server to handle the request. >>>> >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple >>>> thing >>>> >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find >>>> something quite easily. >>>> >> >>>> >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>> >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>>>>>>>> Hey Aziz, >>>> >> >>>> >>>>>>>>>>>>>>>> really thanks for you repl..........so do i >>>> need to >>>> >>>>>>>>>>>>>>>> write a controller action that would return me the >>>> states depending on the >>>> >>>>>>>>>>>>>>>> country and how do i render the state drop down in >>>> Cilent Form...Thanks.... >>>> >> >>>> >>>>>>>>>>>>>>>> Thanks, >>>> >>>>>>>>>>>>>>>> AJ >>>> >> >>>> >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>> >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >> >>>> >>>>>>>>>>>>>>>>> Hey AJ >>>> >> >>>> >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the >>>> selected >>>> >>>>>>>>>>>>>>>>> state if you are using a nested resource url >>>> structure. >>>> >>>>>>>>>>>>>>>>> Your js would looks something like this: >>>> >> >>>> >>>>>>>>>>>>>>>>> $(document).ready(function() { >>>> >>>>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>> >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>> >> >>>> >> ... >>>> >> >>>> >> read more » >>>> > >>>> > -- >>>> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> > To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> > For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> > >>>> >>>> >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Hey Akshar Good to see that you got it working. On Fri, May 4, 2012 at 2:51 PM, akshar jamgaonkar < akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Guys... All of You... Thanks alot...... i have achieved it........i > was struglling on it from 2 3 days....and without all of your help i > wouldnt have successeded...... RUBY ON RAILS ROCK....thanks > > > On Thu, May 3, 2012 at 7:31 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> >> >> On 3 May 2012 14:38, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> HEy cool.. Thanks a lot...it worked however with state drop down i also >>> iam getting a lot of other un necessary html...... The html is what i have >>> written in application.html.erb for templating purpose....... Is this the >>> wrong way to write static html code in application.html.erb... Thanks a >>> lot.... >> >> >> You need to tell your view not render the layout. You should read the >> Rails guide to rendering and layouts. I''ll let you figure it out from there: >> http://guides.rubyonrails.org/layouts_and_rendering.html >> >> Just for your reference, I feel that a better way of achieving what >> you''re doing would be: >> * Have nested routes for countries and states and call the url at >> /countries/1/states.json ( >> http://guides.rubyonrails.org/routing.html#nested-resources) >> * Have the index method of the StatesController respond to the .json >> request and render the states back as a JSON array. Let the browser and >> create the <option> tags using Javascript. >> >> IMHO that way is quicker, slicker and more maintainable. >> >> Also, in your current form, you could replace your $.ajax method with: >> >> $.get(country_states_path+country_id, function(data) { >> $("#client_state_id").replaceWith(data); >> } >> }); >> >> Hope that''s helpful. >> >> >>> On Thu, May 3, 2012 at 7:02 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> >>>> >>>> On 3 May 2012, at 14:24, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8@public.gmane.orgm> >>>> wrote: >>>> >>>> Yes i have a Select box with this id = "client_state_id" .. when i >>>> run $("#client_state_id") the select drop down control gets highlighted. >>>> Thanks >>>> >>>> >>>> Try using replaceWith() instead of html() in your success function. >>>> >>>> >>>> On Thu, May 3, 2012 at 6:46 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> >>>>> >>>>> On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>> > Hello All, >>>>> > >>>>> > ill just summarize everything in this message..kindly suggest as to >>>>> > what might be wrong >>>>> >>>>> Do you have a div with the id of "client_state_id"? What do you get if >>>>> you run $("#client_state_id") in firebug? >>>>> >>>>> Jeremy Walker >>>>> >>>>> > >>>>> > >>>>> > >>>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>>> > Iam trying to achiev a functionlity of state drop down >>>>> > been populated on click of country........i have achieved almost 90% >>>>> > of this......iam getting appropriate responce in my firebug. responce >>>>> > is like this when i click india..... >>>>> > >>>>> > <select id="states_state_id" name="states[state_id]"><option >>>>> > value="2">Goa</option></select> >>>>> > >>>>> > >>>>> > my application .js looks like this >>>>> > >>>>> > $(document).ready(function() { >>>>> > var country_states_path = ''/states/countries_state/''; >>>>> > $("#client_country_id").change(function() { >>>>> > var country_id = $(this).val(); >>>>> > $.ajax({ >>>>> > type: "GET", >>>>> > data: {country: country_id}, >>>>> > url: country_states_path+country_id, >>>>> > success: function(data) { >>>>> > $("#client_state_id").html(data) >>>>> > } >>>>> > }); >>>>> > }); >>>>> > }); >>>>> > >>>>> > >>>>> > >>>>> > the controller state has an action like this >>>>> > >>>>> > def countries_state >>>>> > @state = State.where("country_id = :c_id",{:c_id => >>>>> > params[:country_id]}) >>>>> > respond_to do |format| >>>>> > format.js >>>>> > end >>>>> > end >>>>> > >>>>> > >>>>> > >>>>> > and template for this action is like >>>>> > >>>>> > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) >>>>> %> >>>>> > >>>>> > >>>>> > However i am getting the response in firebug but the html on page is >>>>> > not updated. Iam trying to find but iam stuck as iam a bit new to all >>>>> > this. >>>>> > >>>>> > >>>>> > Please suggest as to what might be wrong. thanks a lot >>>>> > >>>>> > >>>>> > Thanks & Regards, >>>>> > Akshar >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>>> > >>>>> > >>>>> > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>> > wrote: >>>>> >> Hi all, >>>>> >> >>>>> >> I have succesfully got a responce like this as to what i want , >>>>> this is the >>>>> >> ouptut in my fireofx console. >>>>> >> >>>>> >> <select id="states_state_id" name="states[state_id]"><option >>>>> >> value="1">Maharashtra</option></select>. >>>>> >> >>>>> >> but the html on the page is not updating.......any reson why this >>>>> could be >>>>> >> ...thanks a lot.... >>>>> >> >>>>> >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < >>>>> >> >>>>> >> >>>>> >> >>>>> >> >>>>> >> >>>>> >> >>>>> >> >>>>> >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>> Also in the def countries_state >>>>> >>> @state = State.where("country_id = :c_id",{:c_id => >>>>> params[:country_id]}) >>>>> >>> respond_to do |format| >>>>> >>> format.html >>>>> >>> end >>>>> >>> end >>>>> >> >>>>> >>> previously the it was format.js when nothing on the page was >>>>> changing >>>>> >>> dynamically but when i make it format.html, the state drop down >>>>> changes but >>>>> >>> i get all the unnecessary thing like the the entire html page. >>>>> >> >>>>> >>> Thanks >>>>> >> >>>>> >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < >>>>> >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>> Hi Aziz.... >>>>> >> >>>>> >>>> Iam getting whatevr reponce iam nneding,....... Thansk a >>>>> lot.....in >>>>> >>>> the console in firbug when i see i get the states for a specific >>>>> >>>> counytry.....The responce is like "[["Goa", 2]]" .... >>>>> however >>>>> >>>> whatever processing i do in application.js in not taking >>>>> effect,,,,,, >>>>> >> >>>>> >>>> My application.js is >>>>> >> >>>>> >>>> $(document).ready(function() { >>>>> >>>> var country_states_path = ''/states/countries_state/''; >>>>> >>>> $("#client_country_id").change(function() { >>>>> >>>> var country_id = $(this).val(); >>>>> >>>> $.ajax({ >>>>> >>>> type: "GET", >>>>> >>>> data: {country: country_id}, >>>>> >>>> url: country_states_path+country_id, >>>>> >>>> success: function(data) { >>>>> >>>> $("#client_country_id").html(data) >>>>> >>>> } >>>>> >>>> }); >>>>> >>>> }); >>>>> >>>> }); >>>>> >> >>>>> >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala < >>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>> >> >>>>> >>>>> Not a problem. >>>>> >> >>>>> >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >>>>> >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help >>>>> >> >>>>> >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala < >>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>> >> >>>>> >>>>>>> That is fine, though you could make it more ''RESTful'' by >>>>> adding it as >>>>> >>>>>>> a nested resource. You can read about that here< >>>>> http://railscasts.com/episodes/139-nested-resources>. >>>>> >>>>>>> The RailsCast is a little old, but you should get the idea. >>>>> >> >>>>> >>>>>>> With respect to your current problem, what is the url you are >>>>> using in >>>>> >>>>>>> your js? >>>>> >> >>>>> >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>>>> >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>> Iam sorry i didnt get you.......... i have created a new >>>>> action for >>>>> >>>>>>>> the ajax stuff is this approach wrong..... This is how my >>>>> states controller >>>>> >>>>>>>> is >>>>> >> >>>>> >>>>>>>> >>>>> --------------------------------------------------------------------------- >>>>> --------------------------------------------------------------------------- >>>>> ----------------------------------- >>>>> >> >>>>> >>>>>>>> class StatesController < ApplicationController >>>>> >>>>>>>> # GET /states >>>>> >>>>>>>> # GET /states.json >>>>> >>>>>>>> def index >>>>> >>>>>>>> @states = State.all >>>>> >> >>>>> >>>>>>>> respond_to do |format| >>>>> >>>>>>>> format.html # index.html.erb >>>>> >>>>>>>> format.json { render json: @states } >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> # GET /states/1 >>>>> >>>>>>>> # GET /states/1.json >>>>> >>>>>>>> def show >>>>> >>>>>>>> @state = State.find(params[:id]) >>>>> >> >>>>> >>>>>>>> respond_to do |format| >>>>> >>>>>>>> format.html # show.html.erb >>>>> >>>>>>>> format.json { render json: @state } >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> # GET /states/new >>>>> >>>>>>>> # GET /states/new.json >>>>> >>>>>>>> def new >>>>> >>>>>>>> @state = State.new >>>>> >>>>>>>> respond_to do |format| >>>>> >>>>>>>> format.html # new.html.erb >>>>> >>>>>>>> format.json { render json: @state } >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> # GET /states/1/edit >>>>> >>>>>>>> def edit >>>>> >>>>>>>> @state = State.find(params[:id]) >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> # POST /states >>>>> >>>>>>>> # POST /states.json >>>>> >>>>>>>> def create >>>>> >>>>>>>> @state = State.new(params[:state]) >>>>> >> >>>>> >>>>>>>> respond_to do |format| >>>>> >>>>>>>> if @state.save >>>>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>>> >>>>>>>> successfully created.'' } >>>>> >>>>>>>> format.json { render json: @state, status: :created, >>>>> >>>>>>>> location: @state } >>>>> >>>>>>>> else >>>>> >>>>>>>> format.html { render action: "new" } >>>>> >>>>>>>> format.json { render json: @state.errors, status: >>>>> >>>>>>>> :unprocessable_entity } >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> def countries_state >>>>> >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => >>>>> params[:country]}) >>>>> >>>>>>>> respond_to do |format| >>>>> >>>>>>>> format.html >>>>> >>>>>>>> format.js >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> # PUT /states/1 >>>>> >>>>>>>> # PUT /states/1.json >>>>> >>>>>>>> def update >>>>> >>>>>>>> @state = State.find(params[:id]) >>>>> >> >>>>> >>>>>>>> respond_to do |format| >>>>> >>>>>>>> if @state.update_attributes(params[:state]) >>>>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>>> >>>>>>>> successfully updated.'' } >>>>> >>>>>>>> format.json { head :ok } >>>>> >>>>>>>> else >>>>> >>>>>>>> format.html { render action: "edit" } >>>>> >>>>>>>> format.json { render json: @state.errors, status: >>>>> >>>>>>>> :unprocessable_entity } >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> # DELETE /states/1 >>>>> >>>>>>>> # DELETE /states/1.json >>>>> >>>>>>>> def destroy >>>>> >>>>>>>> @state = State.find(params[:id]) >>>>> >>>>>>>> @state.destroy >>>>> >> >>>>> >>>>>>>> respond_to do |format| >>>>> >>>>>>>> format.html { redirect_to states_url } >>>>> >>>>>>>> format.json { head :ok } >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >>>>>>>> end >>>>> >> >>>>> >>>>>>>> >>>>> --------------------------------------------------------------------------- >>>>> --------------------------------------------------------------------------- >>>>> ------------------------------------ >>>>> >> >>>>> >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < >>>>> >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>> Make sure ur using the currect URL for the new action. >>>>> >> >>>>> >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>>> >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>> Yea it looks like this... >>>>> >> >>>>> >>>>>>>>>> match "/states/countries_state/:country_id" => >>>>> >>>>>>>>>> "states#countries_state" >>>>> >> >>>>> >>>>>>>>>> resources :clients >>>>> >> >>>>> >>>>>>>>>> resources :skill_sets >>>>> >> >>>>> >>>>>>>>>> resources :technologies >>>>> >> >>>>> >>>>>>>>>> resources :level_of_contacts >>>>> >> >>>>> >>>>>>>>>> resources :states >>>>> >> >>>>> >>>>>>>>>> resources :discounts >>>>> >> >>>>> >>>>>>>>>> resources :countries >>>>> >> >>>>> >>>>>>>>>> resources :roles >>>>> >> >>>>> >>>>>>>>>> get "home/index" >>>>> >> >>>>> >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>>>> >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>>> Make sure this route comes before the route entry for the >>>>> country >>>>> >>>>>>>>>>> resource. >>>>> >> >>>>> >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>> >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>>>> Yes i have added....it looks like this >>>>> >> >>>>> >>>>>>>>>>>> match "/states/countries_state/:country_id" => >>>>> >>>>>>>>>>>> "states#countries_state" >>>>> >> >>>>> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>> >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>>>>> Did you add a route for this new action? >>>>> >> >>>>> >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>> >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state >>>>> action and >>>>> >>>>>>>>>>>>>> in states controller, and in application.js i have >>>>> modified the path like >>>>> >>>>>>>>>>>>>> this >>>>> >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; >>>>> however >>>>> >>>>>>>>>>>>>> on console its giving me eroor like >>>>> >>>>>>>>>>>>>> <pre>Couldn''t find State with id=countries_state</pre> >>>>> ... Iam >>>>> >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty new >>>>> to all >>>>> >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... >>>>> >> >>>>> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>> >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>>>>>>> Hey AJ >>>>> >> >>>>> >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you >>>>> would need >>>>> >>>>>>>>>>>>>>> something on the server to handle the request. >>>>> >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty simple >>>>> thing >>>>> >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find >>>>> something quite easily. >>>>> >> >>>>> >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>> >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>>>>>>>> Hey Aziz, >>>>> >> >>>>> >>>>>>>>>>>>>>>> really thanks for you repl..........so do i >>>>> need to >>>>> >>>>>>>>>>>>>>>> write a controller action that would return me the >>>>> states depending on the >>>>> >>>>>>>>>>>>>>>> country and how do i render the state drop down in >>>>> Cilent Form...Thanks.... >>>>> >> >>>>> >>>>>>>>>>>>>>>> Thanks, >>>>> >>>>>>>>>>>>>>>> AJ >>>>> >> >>>>> >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>> >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >> >>>>> >>>>>>>>>>>>>>>>> Hey AJ >>>>> >> >>>>> >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the >>>>> selected >>>>> >>>>>>>>>>>>>>>>> state if you are using a nested resource url >>>>> structure. >>>>> >>>>>>>>>>>>>>>>> Your js would looks something like this: >>>>> >> >>>>> >>>>>>>>>>>>>>>>> $(document).ready(function() { >>>>> >>>>>>>>>>>>>>>>> var country_states_path = ''/countries/:id/states; >>>>> >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>> >> >>>>> >> ... >>>>> >> >>>>> >> read more » >>>>> > >>>>> > -- >>>>> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> > To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> > For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> > >>>>> >>>>> >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> >>> >>> -- >>> Thanks & Regards, >>> Akshar Jamgaonkar >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Thanks & Regards, > Akshar Jamgaonkar > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- - Aziz M. Bookwala Website <http://azizmb.in> | Twitter <https://twitter.com/azizbookwala> | Github <http://github.com/azizmb> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Yea Aziz....thanks a lot On Sat, May 5, 2012 at 11:31 AM, Aziz Bookwala <aziz.bookwala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hey Akshar > > Good to see that you got it working. > > > On Fri, May 4, 2012 at 2:51 PM, akshar jamgaonkar < > akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hey Guys... All of You... Thanks alot...... i have achieved it........i >> was struglling on it from 2 3 days....and without all of your help i >> wouldnt have successeded...... RUBY ON RAILS ROCK....thanks >> >> >> On Thu, May 3, 2012 at 7:31 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> >>> >>> On 3 May 2012 14:38, akshar jamgaonkar <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>> >>>> HEy cool.. Thanks a lot...it worked however with state drop down i also >>>> iam getting a lot of other un necessary html...... The html is what i have >>>> written in application.html.erb for templating purpose....... Is this the >>>> wrong way to write static html code in application.html.erb... Thanks a >>>> lot.... >>> >>> >>> You need to tell your view not render the layout. You should read the >>> Rails guide to rendering and layouts. I''ll let you figure it out from there: >>> http://guides.rubyonrails.org/layouts_and_rendering.html >>> >>> Just for your reference, I feel that a better way of achieving what >>> you''re doing would be: >>> * Have nested routes for countries and states and call the url at >>> /countries/1/states.json ( >>> http://guides.rubyonrails.org/routing.html#nested-resources) >>> * Have the index method of the StatesController respond to the .json >>> request and render the states back as a JSON array. Let the browser and >>> create the <option> tags using Javascript. >>> >>> IMHO that way is quicker, slicker and more maintainable. >>> >>> Also, in your current form, you could replace your $.ajax method with: >>> >>> $.get(country_states_path+country_id, function(data) { >>> $("#client_state_id").replaceWith(data); >>> } >>> }); >>> >>> Hope that''s helpful. >>> >>> >>>> On Thu, May 3, 2012 at 7:02 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>> >>>>> >>>>> >>>>> On 3 May 2012, at 14:24, akshar jamgaonkar < >>>>> akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>> Yes i have a Select box with this id = "client_state_id" .. when i >>>>> run $("#client_state_id") the select drop down control gets highlighted. >>>>> Thanks >>>>> >>>>> >>>>> Try using replaceWith() instead of html() in your success function. >>>>> >>>>> >>>>> On Thu, May 3, 2012 at 6:46 PM, Jeremy Walker <jez.walker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>> >>>>>> >>>>>> >>>>>> On 3 May 2012, at 14:06, AJ <akshar.jamgaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>> > Hello All, >>>>>> > >>>>>> > ill just summarize everything in this message..kindly suggest as to >>>>>> > what might be wrong >>>>>> >>>>>> Do you have a div with the id of "client_state_id"? What do you get >>>>>> if you run $("#client_state_id") in firebug? >>>>>> >>>>>> Jeremy Walker >>>>>> >>>>>> > >>>>>> > >>>>>> > >>>>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>>>> > Iam trying to achiev a functionlity of state drop down >>>>>> > been populated on click of country........i have achieved almost 90% >>>>>> > of this......iam getting appropriate responce in my firebug. >>>>>> responce >>>>>> > is like this when i click india..... >>>>>> > >>>>>> > <select id="states_state_id" name="states[state_id]"><option >>>>>> > value="2">Goa</option></select> >>>>>> > >>>>>> > >>>>>> > my application .js looks like this >>>>>> > >>>>>> > $(document).ready(function() { >>>>>> > var country_states_path = ''/states/countries_state/''; >>>>>> > $("#client_country_id").change(function() { >>>>>> > var country_id = $(this).val(); >>>>>> > $.ajax({ >>>>>> > type: "GET", >>>>>> > data: {country: country_id}, >>>>>> > url: country_states_path+country_id, >>>>>> > success: function(data) { >>>>>> > $("#client_state_id").html(data) >>>>>> > } >>>>>> > }); >>>>>> > }); >>>>>> > }); >>>>>> > >>>>>> > >>>>>> > >>>>>> > the controller state has an action like this >>>>>> > >>>>>> > def countries_state >>>>>> > @state = State.where("country_id = :c_id",{:c_id => >>>>>> > params[:country_id]}) >>>>>> > respond_to do |format| >>>>>> > format.js >>>>>> > end >>>>>> > end >>>>>> > >>>>>> > >>>>>> > >>>>>> > and template for this action is like >>>>>> > >>>>>> > <%= select("states", "state_id", @state.collect{|s| [s.name,s.id]}) >>>>>> %> >>>>>> > >>>>>> > >>>>>> > However i am getting the response in firebug but the html on page >>>>>> is >>>>>> > not updated. Iam trying to find but iam stuck as iam a bit new to >>>>>> all >>>>>> > this. >>>>>> > >>>>>> > >>>>>> > Please suggest as to what might be wrong. thanks a lot >>>>>> > >>>>>> > >>>>>> > Thanks & Regards, >>>>>> > Akshar >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- >>>>>> > >>>>>> > >>>>>> > On May 3, 5:52 pm, akshar jamgaonkar <akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>> > wrote: >>>>>> >> Hi all, >>>>>> >> >>>>>> >> I have succesfully got a responce like this as to what i want , >>>>>> this is the >>>>>> >> ouptut in my fireofx console. >>>>>> >> >>>>>> >> <select id="states_state_id" name="states[state_id]"><option >>>>>> >> value="1">Maharashtra</option></select>. >>>>>> >> >>>>>> >> but the html on the page is not updating.......any reson why this >>>>>> could be >>>>>> >> ...thanks a lot.... >>>>>> >> >>>>>> >> On Thu, May 3, 2012 at 5:58 PM, akshar jamgaonkar < >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> >>>>>> >> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>> Also in the def countries_state >>>>>> >>> @state = State.where("country_id = :c_id",{:c_id => >>>>>> params[:country_id]}) >>>>>> >>> respond_to do |format| >>>>>> >>> format.html >>>>>> >>> end >>>>>> >>> end >>>>>> >> >>>>>> >>> previously the it was format.js when nothing on the page was >>>>>> changing >>>>>> >>> dynamically but when i make it format.html, the state drop down >>>>>> changes but >>>>>> >>> i get all the unnecessary thing like the the entire html page. >>>>>> >> >>>>>> >>> Thanks >>>>>> >> >>>>>> >>> On Thu, May 3, 2012 at 5:47 PM, akshar jamgaonkar < >>>>>> >>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>> Hi Aziz.... >>>>>> >> >>>>>> >>>> Iam getting whatevr reponce iam nneding,....... Thansk a >>>>>> lot.....in >>>>>> >>>> the console in firbug when i see i get the states for a specific >>>>>> >>>> counytry.....The responce is like "[["Goa", 2]]" .... >>>>>> however >>>>>> >>>> whatever processing i do in application.js in not taking >>>>>> effect,,,,,, >>>>>> >> >>>>>> >>>> My application.js is >>>>>> >> >>>>>> >>>> $(document).ready(function() { >>>>>> >>>> var country_states_path = ''/states/countries_state/''; >>>>>> >>>> $("#client_country_id").change(function() { >>>>>> >>>> var country_id = $(this).val(); >>>>>> >>>> $.ajax({ >>>>>> >>>> type: "GET", >>>>>> >>>> data: {country: country_id}, >>>>>> >>>> url: country_states_path+country_id, >>>>>> >>>> success: function(data) { >>>>>> >>>> $("#client_country_id").html(data) >>>>>> >>>> } >>>>>> >>>> }); >>>>>> >>>> }); >>>>>> >>>> }); >>>>>> >> >>>>>> >>>> On Thu, May 3, 2012 at 5:36 PM, Aziz Bookwala < >>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>>> >> >>>>>> >>>>> Not a problem. >>>>>> >> >>>>>> >>>>> On Thu, May 3, 2012 at 5:32 PM, akshar jamgaonkar < >>>>>> >>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>> Thanks Aziz ....thanks a lot...really appriaciate your help >>>>>> >> >>>>>> >>>>>> On Thu, May 3, 2012 at 5:31 PM, Aziz Bookwala < >>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >>>>>> >> >>>>>> >>>>>>> That is fine, though you could make it more ''RESTful'' by >>>>>> adding it as >>>>>> >>>>>>> a nested resource. You can read about that here< >>>>>> http://railscasts.com/episodes/139-nested-resources>. >>>>>> >>>>>>> The RailsCast is a little old, but you should get the idea. >>>>>> >> >>>>>> >>>>>>> With respect to your current problem, what is the url you are >>>>>> using in >>>>>> >>>>>>> your js? >>>>>> >> >>>>>> >>>>>>> On Thu, May 3, 2012 at 5:23 PM, akshar jamgaonkar < >>>>>> >>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>> Iam sorry i didnt get you.......... i have created a new >>>>>> action for >>>>>> >>>>>>>> the ajax stuff is this approach wrong..... This is how my >>>>>> states controller >>>>>> >>>>>>>> is >>>>>> >> >>>>>> >>>>>>>> >>>>>> --------------------------------------------------------------------------- >>>>>> --------------------------------------------------------------------------- >>>>>> ----------------------------------- >>>>>> >> >>>>>> >>>>>>>> class StatesController < ApplicationController >>>>>> >>>>>>>> # GET /states >>>>>> >>>>>>>> # GET /states.json >>>>>> >>>>>>>> def index >>>>>> >>>>>>>> @states = State.all >>>>>> >> >>>>>> >>>>>>>> respond_to do |format| >>>>>> >>>>>>>> format.html # index.html.erb >>>>>> >>>>>>>> format.json { render json: @states } >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> # GET /states/1 >>>>>> >>>>>>>> # GET /states/1.json >>>>>> >>>>>>>> def show >>>>>> >>>>>>>> @state = State.find(params[:id]) >>>>>> >> >>>>>> >>>>>>>> respond_to do |format| >>>>>> >>>>>>>> format.html # show.html.erb >>>>>> >>>>>>>> format.json { render json: @state } >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> # GET /states/new >>>>>> >>>>>>>> # GET /states/new.json >>>>>> >>>>>>>> def new >>>>>> >>>>>>>> @state = State.new >>>>>> >>>>>>>> respond_to do |format| >>>>>> >>>>>>>> format.html # new.html.erb >>>>>> >>>>>>>> format.json { render json: @state } >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> # GET /states/1/edit >>>>>> >>>>>>>> def edit >>>>>> >>>>>>>> @state = State.find(params[:id]) >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> # POST /states >>>>>> >>>>>>>> # POST /states.json >>>>>> >>>>>>>> def create >>>>>> >>>>>>>> @state = State.new(params[:state]) >>>>>> >> >>>>>> >>>>>>>> respond_to do |format| >>>>>> >>>>>>>> if @state.save >>>>>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>>>> >>>>>>>> successfully created.'' } >>>>>> >>>>>>>> format.json { render json: @state, status: :created, >>>>>> >>>>>>>> location: @state } >>>>>> >>>>>>>> else >>>>>> >>>>>>>> format.html { render action: "new" } >>>>>> >>>>>>>> format.json { render json: @state.errors, status: >>>>>> >>>>>>>> :unprocessable_entity } >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> def countries_state >>>>>> >>>>>>>> @state = State.find("country_id = :c_id",{:c_id => >>>>>> params[:country]}) >>>>>> >>>>>>>> respond_to do |format| >>>>>> >>>>>>>> format.html >>>>>> >>>>>>>> format.js >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> # PUT /states/1 >>>>>> >>>>>>>> # PUT /states/1.json >>>>>> >>>>>>>> def update >>>>>> >>>>>>>> @state = State.find(params[:id]) >>>>>> >> >>>>>> >>>>>>>> respond_to do |format| >>>>>> >>>>>>>> if @state.update_attributes(params[:state]) >>>>>> >>>>>>>> format.html { redirect_to @state, notice: ''State was >>>>>> >>>>>>>> successfully updated.'' } >>>>>> >>>>>>>> format.json { head :ok } >>>>>> >>>>>>>> else >>>>>> >>>>>>>> format.html { render action: "edit" } >>>>>> >>>>>>>> format.json { render json: @state.errors, status: >>>>>> >>>>>>>> :unprocessable_entity } >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> # DELETE /states/1 >>>>>> >>>>>>>> # DELETE /states/1.json >>>>>> >>>>>>>> def destroy >>>>>> >>>>>>>> @state = State.find(params[:id]) >>>>>> >>>>>>>> @state.destroy >>>>>> >> >>>>>> >>>>>>>> respond_to do |format| >>>>>> >>>>>>>> format.html { redirect_to states_url } >>>>>> >>>>>>>> format.json { head :ok } >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >>>>>>>> end >>>>>> >> >>>>>> >>>>>>>> >>>>>> --------------------------------------------------------------------------- >>>>>> --------------------------------------------------------------------------- >>>>>> ------------------------------------ >>>>>> >> >>>>>> >>>>>>>> On Thu, May 3, 2012 at 5:20 PM, Aziz Bookwala < >>>>>> >>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>> Make sure ur using the currect URL for the new action. >>>>>> >> >>>>>> >>>>>>>>> On Thu, May 3, 2012 at 5:18 PM, akshar jamgaonkar < >>>>>> >>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>> Yea it looks like this... >>>>>> >> >>>>>> >>>>>>>>>> match "/states/countries_state/:country_id" => >>>>>> >>>>>>>>>> "states#countries_state" >>>>>> >> >>>>>> >>>>>>>>>> resources :clients >>>>>> >> >>>>>> >>>>>>>>>> resources :skill_sets >>>>>> >> >>>>>> >>>>>>>>>> resources :technologies >>>>>> >> >>>>>> >>>>>>>>>> resources :level_of_contacts >>>>>> >> >>>>>> >>>>>>>>>> resources :states >>>>>> >> >>>>>> >>>>>>>>>> resources :discounts >>>>>> >> >>>>>> >>>>>>>>>> resources :countries >>>>>> >> >>>>>> >>>>>>>>>> resources :roles >>>>>> >> >>>>>> >>>>>>>>>> get "home/index" >>>>>> >> >>>>>> >>>>>>>>>> On Thu, May 3, 2012 at 5:15 PM, Aziz Bookwala < >>>>>> >>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>>> Make sure this route comes before the route entry for the >>>>>> country >>>>>> >>>>>>>>>>> resource. >>>>>> >> >>>>>> >>>>>>>>>>> On Thu, May 3, 2012 at 5:12 PM, akshar jamgaonkar < >>>>>> >>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>>>> Yes i have added....it looks like this >>>>>> >> >>>>>> >>>>>>>>>>>> match "/states/countries_state/:country_id" => >>>>>> >>>>>>>>>>>> "states#countries_state" >>>>>> >> >>>>>> >>>>>>>>>>>> On Thu, May 3, 2012 at 5:10 PM, Aziz Bookwala < >>>>>> >>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>>>>> Did you add a route for this new action? >>>>>> >> >>>>>> >>>>>>>>>>>>> On Thu, May 3, 2012 at 5:08 PM, akshar jamgaonkar < >>>>>> >>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>>>>>> Thanks Aziz....... I have wriiten a countries_state >>>>>> action and >>>>>> >>>>>>>>>>>>>> in states controller, and in application.js i have >>>>>> modified the path like >>>>>> >>>>>>>>>>>>>> this >>>>>> >>>>>>>>>>>>>> var country_states_path = ''/states/countries_state/''; >>>>>> however >>>>>> >>>>>>>>>>>>>> on console its giving me eroor like >>>>>> >>>>>>>>>>>>>> <pre>Couldn''t find State with >>>>>> id=countries_state</pre> ... Iam >>>>>> >>>>>>>>>>>>>> struggling to find what;s going wrong as iam pretty >>>>>> new to all >>>>>> >>>>>>>>>>>>>> this...thanks a lot all of you for your help...... >>>>>> >> >>>>>> >>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:03 PM, Aziz Bookwala < >>>>>> >>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>>>>>>> Hey AJ >>>>>> >> >>>>>> >>>>>>>>>>>>>>> Yes, to serve any request made by your client, you >>>>>> would need >>>>>> >>>>>>>>>>>>>>> something on the server to handle the request. >>>>>> >>>>>>>>>>>>>>> As for rendering the dropdown, this is a pretty >>>>>> simple thing >>>>>> >>>>>>>>>>>>>>> to do with jQuery. Look around, you should find >>>>>> something quite easily. >>>>>> >> >>>>>> >>>>>>>>>>>>>>> On Thu, May 3, 2012 at 5:01 PM, akshar jamgaonkar < >>>>>> >>>>>>>>>>>>>>> akshar.jamgaon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>>>>>>>> Hey Aziz, >>>>>> >> >>>>>> >>>>>>>>>>>>>>>> really thanks for you repl..........so do i >>>>>> need to >>>>>> >>>>>>>>>>>>>>>> write a controller action that would return me the >>>>>> states depending on the >>>>>> >>>>>>>>>>>>>>>> country and how do i render the state drop down in >>>>>> Cilent Form...Thanks.... >>>>>> >> >>>>>> >>>>>>>>>>>>>>>> Thanks, >>>>>> >>>>>>>>>>>>>>>> AJ >>>>>> >> >>>>>> >>>>>>>>>>>>>>>> On Thu, May 3, 2012 at 4:46 PM, Aziz Bookwala < >>>>>> >>>>>>>>>>>>>>>> aziz.bookw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >> >>>>>> >>>>>>>>>>>>>>>>> Hey AJ >>>>>> >> >>>>>> >>>>>>>>>>>>>>>>> In your ajax call, you need to pass the id of the >>>>>> selected >>>>>> >>>>>>>>>>>>>>>>> state if you are using a nested resource url >>>>>> structure. >>>>>> >>>>>>>>>>>>>>>>> Your js would looks something like this: >>>>>> >> >>>>>> >>>>>>>>>>>>>>>>> $(document).ready(function() { >>>>>> >>>>>>>>>>>>>>>>> var country_states_path >>>>>> ''/countries/:id/states; >>>>>> >>>>>>>>>>>>>>>>> $("#client_country_id").change(function() { >>>>>> >> >>>>>> >> ... >>>>>> >> >>>>>> >> read more » >>>>>> > >>>>>> > -- >>>>>> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> > To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> > For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> > >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks & Regards, >>>>> Akshar Jamgaonkar >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks & Regards, >>>> Akshar Jamgaonkar >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit this group at >>>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>>> >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> Thanks & Regards, >> Akshar Jamgaonkar >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > - Aziz M. Bookwala > > Website <http://azizmb.in> | Twitter <https://twitter.com/azizbookwala> | > Github <http://github.com/azizmb> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Thanks & Regards, Akshar Jamgaonkar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.