Fix public_r_tag selection

This commit is contained in:
chris 2013-02-23 16:52:37 +08:00
parent ad9b91f792
commit caac9191ce
4 changed files with 8 additions and 4 deletions

View File

@ -39,7 +39,7 @@ $("#widget_list select,#frontend_list select").live('change', function() {
}); });
$("#tag_list select").live('change', function() { $("#tag_list select").live('change', function() {
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_r_tag_options'); $.getScript($(this).attr('rel') + '?type=' + $(this).val());
}); });
$("select.widget_field_select").live('change', function() { $("select.widget_field_select").live('change', function() {

View File

@ -126,7 +126,8 @@ class Admin::PagePartsController < ApplicationController
end end
def reload_r_tag_options def reload_r_tag_options
@r_tag = (ModuleApp.find(params[:id]) rescue nil) || params[:id] @part = PagePart.find params[:id]
@r_tag = params[:type]
@tag_objects = @r_tag.classify.constantize.all rescue nil @tag_objects = @r_tag.classify.constantize.all rescue nil
respond_to do |format| respond_to do |format|
format.js {} format.js {}

View File

@ -1,5 +1,5 @@
<span id='tag_list'> <span id='tag_list'>
<%= f.select :public_r_tag, LIST[:public_r_tags].collect{|tag| [t(tag), tag]}, {:selected => @r_tag}, {:rel => admin_page_parts_path} %> <%= f.select :public_r_tag, LIST[:public_r_tags].collect{|tag| [t(tag), tag]}, {:selected => @r_tag}, {:rel => reload_r_tag_options_admin_page_part_path(@part)} %>
</span> </span>
<span id='name_list'> <span id='name_list'>

View File

@ -1,5 +1,8 @@
<% if @r_tag.eql?('sub_menu') %> <% if @r_tag.eql?('sub_menu') %>
// $('#name_list select').html("<%= j options_for_select(t(:horizontal) => :horizontal, t(:vertical) => :vertical) %>") // $('#name_list select').html("<%= j options_for_select(t(:horizontal) => :horizontal, t(:vertical) => :vertical) %>")
$('#name_list').html("<%= j hidden_field_tag 'page_part[public_r_tag_object_id]', :value => @part.page.id %>")
<% elsif @tag_objects %>
$('#name_list').html("<%= j select_tag 'page_part[public_r_tag_object_id]', options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %>")
<% else %> <% else %>
$('#name_list select').html("<%= j options_from_collection_for_select(@tag_objects, :id, :title) %>") $('#name_list').empty()
<% end %> <% end %>