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(){
$(this).after("<span id='show_preview'></span>");
$.ajax({
type:"PUT",
type:"put",
url:$(this).attr("href"),
data:$(this).parents("form").serialize()
}).done(function(){ $("#"+start_modal_with_id).modal('show');});

View File

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

View File

@ -4,7 +4,7 @@
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Add AdBanner</h3>
<h3><%= t("admin.ad.new_banner") %></h3>
</div>
<div class="modal-body form-horizontal">
@ -30,7 +30,7 @@
</div>
<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>
</div>
<% 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");