Ruby on Rails - observe_field, rjs partial not displayed when editing main form
I am using observe_field to read a textfield and based on the value from that textfield, i am displaying a partial via rjs.
Main form code:
<%= f.text_field :playerId %>
<%= observe_field("submission_playerId", :frequency => 1,
:url => { :controller => 'submissions', :action => :display_player_name },
:with => "'id='+value") %>
<div id="span1"></div>
display_player_name.rjs:
page.replace_html "span1"开发者_如何学JAVA, :partial => "playerName"
_playerName.html.erb:
<p>Player Name: <%= @submission.player.playername %> </p>
The problem is that the partial 'playerName' is only rendered when i make a change to the textfield 'text_field :playerId'. If for example, i am editing the main form, the partial is not displayed unless i change the player id.
I want the partial to be displayed in the first place when i click on the edit button to edit the form, and not only when i change the playerId.
Is there a way of doing that?
Do this in the edit.rb code:
<%= render :partial => 'playerName' %>
精彩评论