Thank u Nithin for your detailed explanation...
But i am still not able to do the ajax functionality...
I hav added <%= javascript_include_tag :defaults %> in my "admin" layout
Controller :
class ReadingsController < ApplicationController
layout "admin"
def index
@time=Time.now
@locations= Station.find(:all,:group => "state",:order =>"state")
@district=Station.find(:all)
@readings= CurrentReading.find(:all)
@range=ConfigureParameter.find(:all)
end
def show_readings_for_state
@district = Station.find_all_by_state_id(params[:state_id])
respond_to do |format|
format.js
end
end
end
readings/index.html.erb
<% form_for :station ,:url => {:action => 'index',:id => @station } do
|f| %>
<center><b> <%= f.label :Stations %></b>
<%= f.collection_select(:state, @locations, :id, :state,{},{:onclick
=>remote_function(:url =>"/readings/show_readings_for_state",:with
=>"'state_id='+this.value+'")} ) %>
</center>
<br/><br/>
<table cellpadding="5">
<tr>
<th>Stations</th>
<th>Time Stamp</th>
<% for sensor_type in @range %>
<th><%= sensor_type.Parameters %></th>
<% end %>
</tr>
<div id="reading_list_div">
<% for loc in @district %>
<tr>
<td>
<%=f.radio_button :contact_preference, "0", :tabindex
=>loc.id %> <%=h loc.district %>
</td>
</tr>
<%end%>
</div>
</table> <br/>
<%end%>
show_readings_for_state.rjs
page.replace_html :reading_list_div, :partial=>'readings_list' ,
:object=>@district
page.visual_effect :highlight, 'reading_list_div'
_readings_list.html.erb
<% for loc in @district %>
<%= radio_button :contact_preference, "0", :tabindex =>loc.id %>
<%=h loc.district %>
<%end%>
This is the code.please look at it and help me.
Thank you,
Veena
--
Posted via http://www.ruby-forum.com/.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.