学校选择形式改为弹窗

This commit is contained in:
Wen 2014-04-23 09:22:13 +08:00
parent 3dbe7c5896
commit 7be7fd3d9b
4 changed files with 49 additions and 3 deletions

View File

@ -6,9 +6,11 @@ class SchoolController < ApplicationController
options = ""
@school.each do |s|
options << "<option value=#{s.id}>#{s.name}</option>"
#options << "<option value=#{s.id}>#{s.name}</option>"
options << "<li><a id=#{s.id} onclick='test(this.id, this.text)'>#{s.name}</a></li>"
end
render :text => options
end

View File

@ -10,6 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "jquery.leanModal.min" %>
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>

View File

@ -1,3 +1,16 @@
<script type="text/javascript">
$(document).ready(
function(){
$("#province").attr("href", "#OpenWindow")
$("#province").leanModal({top: 100, closeButton: ".modal_close"});
}
);
</script>
<script type="text/javascript">
function get_options(value){
$.ajax({
@ -5,13 +18,18 @@
url :'/school/get_options/'+encodeURIComponent(value),
data :'text',
success: function(data){
$("#occupation").html(data);
$("#schoollist").html(data);
}
}
)
}
</script>
@ -88,12 +106,35 @@
-->
<!-- added by Wen -->
<p style="width:357px;padding-left: 26px;">
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span><%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onchange => "get_options(this.value)" %>
<%= select_tag "occupation" %>
<!-- <input id="occupation" readonly />-->
</p>
<div id="OpenWindow">
<a class="modal_close" href="#"></a>
<h2>学校列表</h2>
<div class="content" style="font-size: 13px">
<ul id="schoollist">
</ul>
</div>
</div>
<script type="text/javascript">
function test(id, name){
$("#occupation").html("<option value='"+id+"'>"+name+"</option>");
$("#lean_overlay").hide();
$("#OpenWindow").hide();
}
</script>
<!-- added by bai 增加了地区 -->

View File

@ -12,12 +12,14 @@
<tr>
<td><%= user.lastname %><%= user.firstname %></td>
<td><%= calculate_collaboration_count(user) %></td>
<!-- <td><%= calculate_collaboration_count(user) %></td>
<td><%= calculate_influence_count(user) %></td>
<td><%= calculate_skill_count(user) %></td>
<td><%= calculate_file(user) %></td>
<td><%= calculate_issue(user) %></td>
<td><%= calculate_level(user) %></td>
-->
<td><%= user.changesets.count %></td>
</tr>
<% end %>
</table>