I have the following code in my index.rhtml:
<%= render(:partial => ‘form’) %>
…and the following in my _form.rhtml
<%= form_remote_tag(:update => “images_div_main”,
:url => { :action =>
‘get_reordered_images’}) %>
How many images?
<%= text_field_tag :numreq %>
<%= submit_tag “Click to get images” %>
<%= end_form_tag %>
…and of course, this im my Mycontroller_controller.rb:
def get_reordered_images
@sock_serv = TCPSocket.new(“192.168.107.7”, 9000)
xml = “<?xml version='1.0' ?>”
@sock_serv.send(xml,0)
@results = @sock_serv.recv(1000)
@sock_serv.close
render(:layout => false)
end
and I even have this in my get_reordered_images.rhtml file:
<%= @results %>
It works great! Gets me what I want, where I want it on the page. But
what I also want to do, is “execute” this “action” when the page is
first rendered. I feel like I should just “call” this from the index
page, perhaps is ruby brackets, but I’ve spent ours and nothing happens
until I do the form_remote_tag click and then the “replacement” partial
page appears.
What do I need to do to have “get_reorder_images” execute on first
rendering of html.
Eventually, I will put in logic or a new “action” so that some
parameters are passed with subsequent calls, but this first call has a
default mode.
Thanks,
Dave