AdImage and AnBanner JS fixed

This commit is contained in:
Matthew K. Fu JuYuan 2012-04-18 15:26:59 +08:00 committed by Christophe Vilayphiou
parent 81b0046f42
commit 0c46b4da23
6 changed files with 22 additions and 9 deletions

View File

@ -6,7 +6,7 @@ $(document).ready(function() {
$("a.preview_trigger").click(function(){ $("a.preview_trigger").click(function(){
$(this).after("<span id='show_preview'></span>"); $(this).after("<span id='show_preview'></span>");
$.ajax({ $.ajax({
type:"PUT", type:"put",
url:$(this).attr("href"), url:$(this).attr("href"),
data:$(this).parents("form").serialize() data:$(this).parents("form").serialize()
}).done(function(){ $("#"+start_modal_with_id).modal('show');}); }).done(function(){ $("#"+start_modal_with_id).modal('show');});

View File

@ -22,9 +22,14 @@ class Admin::AdBannersController < ApplicationController
def create def create
@ad_banner = AdBanner.new(params[:ad_banner]) @ad_banner = AdBanner.new(params[:ad_banner])
@ad_banner.save if @ad_banner.save
redirect_to admin_ad_banners_url @active = @ad_banner
respond_to do |format|
format.js {render 'new_created_node'}
end
else
render 'create_error_msg'
end
end end
def edit def edit
@ -40,8 +45,8 @@ class Admin::AdBannersController < ApplicationController
end end
def realtime_preview def realtime_preview
@ad_banner = AdBanner.find(conditions: { title: params[:title] }).preview_clone @ad_banner = AdBanner.first(conditions: { title: params[:title] }).preview_clone
#@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images]) @ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images])
end end
def index def index

View File

@ -4,7 +4,7 @@
<div class="modal-header"> <div class="modal-header">
<a class="close" data-dismiss="modal">×</a> <a class="close" data-dismiss="modal">×</a>
<h3>Add AdBanner</h3> <h3><%= t("admin.ad.new_banner") %></h3>
</div> </div>
<div class="modal-body form-horizontal"> <div class="modal-body form-horizontal">
@ -30,7 +30,7 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %> <%= f.submit t('submit'), :class=>'btn btn-primary',:remote=>true %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a> <a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div> </div>
<% end %> <% end %>

View File

@ -0,0 +1 @@
alert("Error occures:<%= @ad_banner.errors.full_messages%>");

View File

@ -0,0 +1,7 @@
$('<%= escape_javascript(content_tag(:li,link_to(@ad_banner.title,"##{@ad_banner.title}",:data=>{:toggle=>"tab"}))) %>').insertBefore("#new_ad_banner_tab_but");
$('<%= escape_javascript(render(:partial => "ad_banner_tab",:locals => {:ad_banner_tab => @ad_banner})) %>').insertBefore($("#new-a-banner"));
$('.modal').modal('hide');
$('#post-body-content').find(".nav.nav-tabs").children('li.active').removeClass("active");
$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");