Saturday 15 August 2015

ajax - Why is my hidden_field being ignored? Not passing parameter -


I am trying to subscribe to BTN back and backward using Ajax but doing nothing in the hidden area is. I have tried to set one, value: 4 or even wrapping the form in escape_jpg is still not shown.

relationship / destroy.js.erb:

  $ ("# unfollow_ of <% = @ user.id%>") replaceWith ('. & Lt; div id = "follow_key" & lt;% = @ user.id%> & gt; & lt;% = form_for (current_user.relationships .build (followed_id: @ user.id), remote: true | F | f.hidden_field: followed_id f.submit "subscribe" end%>  '  

logs: "/ Relationships" started for the

  127.0.0.1 2013-06-21 05:38:46 -0400 Make the processing controller # js as parameter by relationships: {"utf8" = & gt; ; "One ????" "Authenticity_token" = & gt; "Jx9SG25KLJH5UfstrOw3RudtgqJtKwidvT4xGt + bqas =", "committed" => Select "One Subscription ????"} User Load (0.4ms) "those" * "Those" where "those" "remember_token" = '1gPcW8-7ey4aSGV-g1O_lw' in range 1 2ms NoMethodError with full 500 internal server error (for the undefined method `[] 'zero: NilClass). Application / controller / relationships_controller RB: 6: In the "create"   

The GUI post has lost this parameter (input is also missing in html):

  " Relationship "= & gt; {"Followed_id" =>, "46"} & lt; Input id = "relationship_followed_id" name = "relationship [follow_id]" type = "hidden" value = "92" />   

When I try:

  f.hidden_field followed_id: @ user.id   

undefined method to me Finds `{: followed_id = & gt; 2} For '#ControllerController kick:

  make def @user = User.find (parameter [: relationships] [: followed_id]) Current_user.follow ! (@ User) response_to do | Format | Format.html {redirect_to: back} format.js end end def dislikes @username = relationship review (params [: id]). After the current_user.unfollow! (@ User) response_to do | Format | Format.html {redirect_to: back} format.js End and    

optional

it _partial_form.html. Save as ARB

  & lt; Div id = "follow_key";% = @ user.id% & gt; & Gt; & Lt;% = form_for (current_user.relationships.build (follow _id: @ user.id), remote: true) do | F | & Gt%; & Lt;% = f.hidden_field: followed_id% & gt; & Lt;% = f.submit "Subscribe"% & gt; & Lt;% = end% & gt; & Lt; / Div & gt;   

In your js.erb

  $ (selector) .replaceWith ('& lt;% = j render' path to your partial_form '% & Gt; ')   

And make sure your follow-up is the value of the value, to create the test value,

  <% = f.hidden_field : Followed_id ,: value = & gt; 18% & gt;    

No comments:

Post a Comment