我有一个会议模型:
class Meeting < ActiveRecord::Base
has_one :location, :class_name => "MeetingLocation", :dependent => :destroy
accepts_nested_attributes_for :location
Run Code Online (Sandbox Code Playgroud)
然后我有一个MeetingLocation模型:
class MeetingLocation < ActiveRecord::Base
belongs_to :meeting
Run Code Online (Sandbox Code Playgroud)
我的新会议表格:
<%= form_for @meeting do |f| %>
<%= f.label :location %>
<%= fields_for :location do |l| %>
Name <%= l.text_field :name %>
Street <%= l.text_field :street %>
City <%= l.text_field :city, :class => "span2" %>
State <%= l.select :state, us_states, :class => "span1" %>
Zipcode <%= l.text_field :zip, :class => "span1" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
当我查看新会议表单时,位置字段为空!我只看到位置标签,但没有其他位置字段.我一直在寻找过去3个小时的解释,发现很多类似的问题,但没有运气.
谢谢.
我有以下使用date_select ..
<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :html => {:class => "select birthday"} %>
Run Code Online (Sandbox Code Playgroud)
但是这个类没有出现在html中..
<select id="profile_birthday_2i" name="profile[birthday(2i)]">
<select id="profile_birthday_3i" name="profile[birthday(3i)]">
Run Code Online (Sandbox Code Playgroud)
我也试过..
<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :class => "select birthday" %>
Run Code Online (Sandbox Code Playgroud)
那也行不通.有任何想法吗?
我正在尝试向我的表单提交操作添加一个数组。请注意,我不想使用 ajax.. 只是在添加此“uids”参数后进行常规提交。
$("#new_meeting").live("submit", function(){
var uids = [];
$("span.receiver-name").each(function(){
var uid_name = $(this).attr("id");
var uid = uid_name.split("--")[0];
uids.push(uid);
})
$("#new_meeting").append("&uids=" + uids);
});
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为在服务器端我没有看到 uids 参数。还有一件事我尝试在stackoverflow上查看其他帖子,但也无法使其正常工作..这就是..
var input = $("<input>").attr("type", "hidden").attr("uids", "mydata").val(uids);
$('#new_meeting').append($(input));
Run Code Online (Sandbox Code Playgroud)
有没有人做过这个?谢谢。
我在这个问题上看过很多帖子,但没有一个解决方案有效.下列..
<script type="text/javascript">
$(document).ready(function() {
$("a.login_linkedinbutton").click(function(){
$("#signup-form").submit();
return false;
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
是我在页面的body标签中的内容.身体也是形式,IE中的html就像这样显示出来.
<form accept-charset="UTF-8" action="/auth/linkedin" class="well form-inline" id="signup-form" method="post">
<a class="login_linkedinbutton" href="#">Login using Linkedin</a>
</form>
Run Code Online (Sandbox Code Playgroud)
在IE8中,当单击表单中的链接时,jquery不会被触发.它适用于Chrome和Firefox.我试过了:
1)使用实时事件绑定单击操作2)将jquery移出页面并移入rails资产
还有什么想法可以尝试吗?