Forum: Ruby on Rails form_remote_tag

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9daf050f0920e17467d55f2e27d2232e?d=identicon&s=25 Pat (Guest)
on 2007-07-06 00:07
I am using form_remote_tag as follows:
<%= form_remote_tag(:update => "sku", :url=>{:action =>:generate_skus})
%>
The problem I am having is the web page will actually change to the
generate_skus page which defeats the purpose of using this. Any ideas on
why it wouldnt update the html code on the current page.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-07-06 00:55
(Received via mailing list)
Pat wrote:

> I am using form_remote_tag as follows:
> <%= form_remote_tag(:update => "sku", :url=>{:action =>:generate_skus})
> %>
> The problem I am having is the web page will actually change to the
> generate_skus page which defeats the purpose of using this. Any ideas on
> why it wouldnt update the html code on the current page.

Post the code that responds to that action.

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax
9daf050f0920e17467d55f2e27d2232e?d=identicon&s=25 Pat (Guest)
on 2007-07-06 01:13
Phlip wrote:
> Pat wrote:
>
>> I am using form_remote_tag as follows:
>> <%= form_remote_tag(:update => "sku", :url=>{:action =>:generate_skus})
>> %>
>> The problem I am having is the web page will actually change to the
>> generate_skus page which defeats the purpose of using this. Any ideas on
>> why it wouldnt update the html code on the current page.
>
> Post the code that responds to that action.
>
> --
>   Phlip
>   http://www.oreilly.com/catalog/9780596510657/
>   "Test Driven Ajax (on Rails)"
>   assert_xpath, assert_javascript, & assert_ajax
controller
          def generate_skus
            @output = "This is not correct"
            render :partial => "generate_skus"
          end
view for _generate_skus
  <%= @output %>
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-07-06 01:25
(Received via mailing list)
>> Pat wrote:
>>
>>> I am using form_remote_tag as follows:
>>> <%= form_remote_tag(:update => "sku", :url=>{:action =>:generate_skus})
>>> %>

I can't help because I just never use :update. I know it's useful...

>          def generate_skus
>            @output = "This is not correct"
>            render :partial => "generate_skus"
>          end
> view for _generate_skus
>  <%= @output %>

I'm also aware that some people don't like to mix model and view code.
But I
would have written the response like this:

   render :update do |page|
       page.replace_html 'sku', @output
   end

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax
1fba4539b6cafe2e60a2916fa184fc2f?d=identicon&s=25 unknown (Guest)
on 2007-07-06 01:31
(Received via mailing list)
Hi --

On Fri, 6 Jul 2007, Pat wrote:

>
> I am using form_remote_tag as follows:
> <%= form_remote_tag(:update => "sku", :url=>{:action =>:generate_skus})
> %>
> The problem I am having is the web page will actually change to the
> generate_skus page which defeats the purpose of using this. Any ideas on
> why it wouldnt update the html code on the current page.

Are you sure you're loading the necessary JavaScript files?  It sounds
like maybe it's falling back on doing a non-Ajax request to your
action.


David

--
* Books:
   RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242)
   RUBY FOR RAILS (http://www.manning.com/black)
* Ruby/Rails training
     & consulting:  Ruby Power and Light, LLC (http://www.rubypal.com)
9daf050f0920e17467d55f2e27d2232e?d=identicon&s=25 Pat (Guest)
on 2007-07-06 01:37
unknown wrote:
> Hi --
>
> On Fri, 6 Jul 2007, Pat wrote:
>
>>
>> I am using form_remote_tag as follows:
>> <%= form_remote_tag(:update => "sku", :url=>{:action =>:generate_skus})
>> %>
>> The problem I am having is the web page will actually change to the
>> generate_skus page which defeats the purpose of using this. Any ideas on
>> why it wouldnt update the html code on the current page.
>
> Are you sure you're loading the necessary JavaScript files?  It sounds
> like maybe it's falling back on doing a non-Ajax request to your
> action.
>
>
> David
>
> --
> * Books:
>    RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242)
>    RUBY FOR RAILS (http://www.manning.com/black)
> * Ruby/Rails training
>      & consulting:  Ruby Power and Light, LLC (http://www.rubypal.com)

I have used
<%= javascript_include_tag :defaults %>
which generates the following javascript
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/effects.js" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js" type="text/javascript"></script>
<script src="/javascripts/controls.js" type="text/javascript"></script>
A73f446eaaf56db0aeaa578aa373989b?d=identicon&s=25 Terry Donaghe (Guest)
on 2007-07-06 19:08
(Received via mailing list)
If I understand what you're saying - your generate_skus partial is being
rendered as a seperate page?

Is your generate_skus partial page named correctly?  It's been a little
while since I fooled with a partial, and I don't have my environment
here
with me, but I think skus are named like "_generate_skus.rhtml" - do you
maybe have a file named "generate_skus.rhtml"?

Or do you have both _generate_skus.rhtml and generate_skus.rhtml in the
same
folder?  Though I wouldn't think that would be a problem.

Sorry if I'm mucking this up with the wrong syntax!  :D


On 7/5/07, Pat <rails-mailing-list@andreas-s.net> wrote:
> >> %>
> > David
> which generates the following javascript
> <script src="/javascripts/prototype.js" type="text/javascript"></script>
> <script src="/javascripts/effects.js" type="text/javascript"></script>
> <script src="/javascripts/dragdrop.js" type="text/javascript"></script>
> <script src="/javascripts/controls.js" type="text/javascript"></script>
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--
Terry (TAD) Donaghe
http://tadspot.tumblr.com
http://www.rubynoob.com
9daf050f0920e17467d55f2e27d2232e?d=identicon&s=25 Pat (Guest)
on 2007-07-08 00:50
I have the _generate_skus.rhtml in the views folder for the controller
that calls it and there is not a generate_skus.rhtml.
This topic is locked and can not be replied to.