Tuesday, March 12, 2013

[Rails] Re: Jquery strange behavior

ok... 
more code.
in tests_controller method which calls js file:

def add_key
   @test=Test.find(params[:id])
   @key=@test.keys.build
   @key.keyword = params[:keyword]
   @key.position = params[:position]
   @answer = generate_answer_field(@key.position)
   respond_to do |format|
   if @key.save then
          format.js
   end
   end
   end

it calls add_key.js.erb with code from first post

in show view link on which jquery called:

<%= link_to(result_array[k], {:controller =>'tests',  :action => 'add_key', :keyword => result_array[k], :position=>k}, :class=>'keyword_links', :method => :post, :remote => true) + str %>

<a href="/tests/143/add_key?keyword=Forever&amp;position=18" class="keyword_links" data-method="post" data-remote="true" rel="nofollow">Forever</a>

And finally to mention, that actually I don't have real route for this link coz all it need to render some form and save smth to database.

Link works - saves that info to database. Problem goes with Jquery.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/JcXyJS4DOL0J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate