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...@gmail.com>
wrote:
> >> 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...@gmail.com> 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>.
> ...
>
> read more »