Just updating:

I have this on a partial:

<p class="fields">
  <%= f.collection_select(:part_id, @parts, :id, :title, { :prompt =>
true } , { :onchange => "load_part_price_select(this.id,
this.options[this.selectedIndex].value);"  } ) %>
  <span class='part_price'> _ _ _ _ </span>
  <%= f.hidden_field :_destroy %>
  <%= link_to_remove_fields "remove", f %>
</p>


and the relative function on application.js file:

function load_part_price_select(id, value) {
        alert(id);
        alert(value);
        $('#' + id ).live('change',function() {
            $.ajax({
                  url: value + '/retrieve_part_price/',
                  success: function(responseData) {
                    alert('test');
                  }
                });
        });
};

For now, I have to figure out a question about routes

I've created the right method on my ItemsController:

  def retrieve_part_price
    @price = Part.find(params[:id])
  end

and configured the routed as:

resources :items do
  get 'retrieve_part_price', :on => :member
end

but the development log shows me an error:


--
Started GET "/items/29/8/retrieve_part_price/" for 127.0.0.1 at
2011-08-10 07:22:57 +0900

ActionController::RoutingError (No route matches "/items/29/8/
retrieve_part_price"):
--

Probably the best way would be something like "/items/29/
retrieve_part_price/8"

But how to make the route act this way?







On Aug 10, 6:54 am, Kleber Shimabuku <[email protected]>
wrote:
> Thank you guys, but as I said in the topic, I looking how to perform
> this on event OnChange of an <select>
>
> On Aug 10, 4:04 am, 7stud -- <[email protected]> wrote:
>
>
>
>
>
>
>
> > You can make your js more general by doing this:
>
> > <h1>Users#new</h1>
> > <p>Find me in app/views/users/new.html.erb</p>
>
> > <%= link_to "Click me",
> >           {:controller => 'users',
> >            :action => 'get_info',
> >            :my_target => 'update_me'},
>
> >            :remote => true %>
>
> > <div id="update_me">Hello</div>
> > <div>world</div>
>
> > ===
>
> > class UsersController < ApplicationController
> >   def new
> >     @title = "Sign up"
> >   end
>
> >   def get_info
> >     @target = params[:my_target]
> >     @data = 'world'
> >   end
>
> > end
>
> > ==app/views/users/get_info.js.erb
>
> > $("<%= @target %>").update("<%= @data %>");
>
> > --
> > Posted viahttp://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.

Reply via email to