Hi!
I am trying to show devices in my database in a table format and in each
column corresponding to one device im trying to give a ping link which will
ping the device and update the result of ping just below the ping link.
What problem im facing is every time first cell is updated for ping result
of any device. this is clearly a problem Related to div id''s , how to
distinguish each cell''s div id''s.
Kindly have a look at my code :
My view looks like:
<table id="myTable" width="800"
border=''1'' >
<thead>
<tr>
<th width="130" scope="col">Device
Name</th>
<th width="70" scope="col">Status</th>
</tr>
</thead>
<tbody>
<% @devices.each do |c|%>
<tr>
<td>
<%=h c.name%>
</td>
<td>
<%= javascript_include_tag:defaults%>
<%= link_to_remote "Ping",:url => {:action =>
''show_ping_ip_addr'',:ipaddr_id=>Ipaddr.find(:first,:conditions
=>["dev_id=?",c.id])} %><br>
<div id="ping_result" style="display:none; ">
</div>
</td>
</tr>
</table>
My controller looks like:
def show_ping_ip_addr
@ipadd=Ipaddr.find_by_id(params[:ipaddr_id])
if system("ping #{@ipadd.address}")
res="Yes it is connected"
else
res="Host unreachable"
end
logger.error "variable is equal to: #{res}"
render :update do |page|
#logger.error "Got here 2"
page.replace_html ''ping_result'', (res || "No
Results").to_s
page.show ''ping_result''
page.visual_effect:highlight, ''ping_result'', :duration
=> 0.2
end
end
Thanx in advance!!
--
View this message in context:
http://www.nabble.com/Update-div-using-render%3Aupdate-tp17960448p17960448.html
Sent from the RubyOnRails Users mailing list archive at Nabble.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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> > What problem im facing is every time first cell is updated for ping result > of any device. this is clearly a problem Related to div id''s , how to > distinguish each cell''s div id''s. >The whole point of ids is that they are unique, if they aren''t results are undefined. Just make them unique (eg append the id of the Ipaddr record). There are even helpers like dom_id, div_for etc... Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I tried to make the id''s unique through the following way:
view now looks like:
<td>
<%= javascript_include_tag:defaults%>
<%= link_to_remote
"Ping",:update=>"ping_result_#{c.id}",:url =>
{:action =>
''show_ping_ip_addr1'',:ipaddr_id=>Ipaddr.find(:first,:conditions
=>["dev_id=?",c.id])} %><br>
<div id="ping_result_#{c.id}" style="display:none; ">
</div>
</td>
and controller:
def show_ping_ip_addr1
@ipadd=Ipaddr.find_by_id(params[:ipaddr_id])
devid=@ipadd.dev_id
if system("ping #{@ipadd.address}")
res="Yes it is connected"
else
res="Host unreachable"
end
logger.error "variable is equal to: #{res}"
render_text "ping"+ res.to_s
end
but its not displaying anything!!
On Wed, Jun 18, 2008 at 12:36 PM, Frederick Cheung <
frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
> >
> > What problem im facing is every time first cell is updated for ping
> result
> > of any device. this is clearly a problem Related to div id''s
, how to
> > distinguish each cell''s div id''s.
> >
> The whole point of ids is that they are unique, if they aren''t
results
> are undefined. Just make them unique (eg append the id of the Ipaddr
> record). There are even helpers like dom_id, div_for etc...
>
> Fred
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi
i tried another way to do it... this time its giving RJS error(Object Error)
view now looks like:
<td>
<%= javascript_include_tag:defaults%>
<%= link_to_remote "Ping",:url => {:action =>
''show_ping_ip_addr'',:ipaddr_id=>Ipaddr.find(:first,:conditions
=>["dev_id=?",c.id])} %><br>
<div id="ping_result_#{c.id}" style="display:none; ">
</div>
and controller:
def show_ping_ip_addr
@ipadd=Ipaddr.find_by_id(params[:ipaddr_id])
devid=@ipadd.dev_id
if system("ping #{@ipadd.address}")
res="Yes it is connected"
else
res="Host unreachable"
end
render :update do |page|
page.replace_html ''ping_result_''+devid.to_s, (res ||
"No
Results").to_s
page.show ''ping_result_''+devid.to_s
page.visual_effect:highlight, ''ping_result_''+devid.to_s,
:duration =>
0.2
end
end
it is correctly identifying unique ids for divs this time in both controller
and view(i checked by putting logger statements around) but i cudnt
understand the cause for error.
Please someone have a look at it.. and help me out!!
Thanx alot!!!
On Wed, Jun 18, 2008 at 1:05 PM, supriya agarwal
<supriya.iiita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> I tried to make the id''s unique through the following way:
>
> view now looks like:
> <td>
> <%= javascript_include_tag:defaults%>
> <%= link_to_remote
"Ping",:update=>"ping_result_#{c.id}",:url =>
> {:action =>
''show_ping_ip_addr1'',:ipaddr_id=>Ipaddr.find(:first,:conditions
> =>["dev_id=?",c.id])} %><br>
> <div id="ping_result_#{c.id}" style="display:none;
">
>
> </div>
> </td>
>
>
> and controller:
> def show_ping_ip_addr1
>
>
> @ipadd=Ipaddr.find_by_id(params[:ipaddr_id])
>
> devid=@ipadd.dev_id
> if system("ping #{@ipadd.address}")
> res="Yes it is connected"
> else
> res="Host unreachable"
> end
> logger.error "variable is equal to: #{res}"
>
> render_text "ping"+ res.to_s
>
>
> end
>
>
> but its not displaying anything!!
>
>
>
> On Wed, Jun 18, 2008 at 12:36 PM, Frederick Cheung <
> frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>>
>>
>> >
>> > What problem im facing is every time first cell is updated for
ping
>> result
>> > of any device. this is clearly a problem Related to div
id''s , how to
>> > distinguish each cell''s div id''s.
>> >
>> The whole point of ids is that they are unique, if they aren''t
results
>> are undefined. Just make them unique (eg append the id of the Ipaddr
>> record). There are even helpers like dom_id, div_for etc...
>>
>> Fred
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Supriya, supriya agarwal wrote:> i tried another way to do it... this time its giving > RJS error(Object Error) > > it is correctly identifying unique ids for divs this time > in both controller and viewPerhaps in the controller, but in looking at your view code, I can''t help but wonder about the rendered page. I''d start by taking the rendered page source (before you try to do any RJS updates on it) and run it through the W3C validator. That''ll tell you real quick if you''ve got unique id''s or not. HTH, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey thanx Bill for replying... I am not sure about your idea.. can you just elaborate it giving an example. Supriya On Wed, Jun 18, 2008 at 7:54 PM, Bill Walton <bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> > Hi Supriya, > > supriya agarwal wrote: > > > i tried another way to do it... this time its giving > > RJS error(Object Error) > > > > it is correctly identifying unique ids for divs this time > > in both controller and view > > Perhaps in the controller, but in looking at your view code, I can''t help > but wonder about the rendered page. I''d start by taking the rendered page > source (before you try to do any RJS updates on it) and run it through the > W3C validator. That''ll tell you real quick if you''ve got unique id''s or > not. > > HTH, > Bill > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey i am able to do it.. small error in my previous code:
<%= link_to_remote
("Ping",:update=>"ping_result_#{c.id}",:url =>
{:action =>
''show_ping_ip_addr1'',:ipaddr_id=>Ipaddr.find(:first,:conditions
=>["dev_id=?",c.id])}) %><br>
<div id="ping_result_<%=c.id%>">
</div>
Thanx!
On Thu, Jun 19, 2008 at 9:49 AM, supriya agarwal
<supriya.iiita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> Hey thanx Bill for replying... I am not sure about your idea.. can you just
> elaborate it giving an example.
>
> Supriya
>
>
> On Wed, Jun 18, 2008 at 7:54 PM, Bill Walton
<bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org>
> wrote:
>
>>
>> Hi Supriya,
>>
>> supriya agarwal wrote:
>>
>> > i tried another way to do it... this time its giving
>> > RJS error(Object Error)
>> >
>> > it is correctly identifying unique ids for divs this time
>> > in both controller and view
>>
>> Perhaps in the controller, but in looking at your view code, I
can''t help
>> but wonder about the rendered page. I''d start by taking the
rendered page
>> source (before you try to do any RJS updates on it) and run it through
the
>> W3C validator. That''ll tell you real quick if you''ve
got unique id''s or
>> not.
>>
>> HTH,
>> Bill
>>
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---