fix preview filed after ad_banner created.
This commit is contained in:
parent
f4692182c0
commit
2c632551e5
|
@ -55,7 +55,7 @@ $(document).ready(function() {
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
|
||||||
$("a.preview_trigger").click(function(){
|
$("a.preview_trigger").live('click',function(){
|
||||||
$("#main-wrap").after("<span id='show_preview'></span>");
|
$("#main-wrap").after("<span id='show_preview'></span>");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
|
|
|
@ -17,7 +17,6 @@ class PagesController < ApplicationController
|
||||||
def show
|
def show
|
||||||
#begin
|
#begin
|
||||||
@item = Item.first(:conditions => {:path => params[:page_name]})
|
@item = Item.first(:conditions => {:path => params[:page_name]})
|
||||||
#binding.pry
|
|
||||||
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
||||||
impressionist(@item)
|
impressionist(@item)
|
||||||
case @item.class.to_s
|
case @item.class.to_s
|
||||||
|
@ -66,6 +65,7 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
def get_item
|
def get_item
|
||||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||||
|
|
||||||
if !params[:category_id].blank? && !params[:tag_id].blank?
|
if !params[:category_id].blank? && !params[:tag_id].blank?
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
|
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
|
||||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
|
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
|
||||||
|
@ -75,6 +75,7 @@ class PagesController < ApplicationController
|
||||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
|
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
|
||||||
end
|
end
|
||||||
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
|
||||||
|
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).first unless @item
|
||||||
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
|
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,8 @@ $("#ad_banner-tab-content").children(".tab-pane").removeClass("active");
|
||||||
$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");
|
$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");
|
||||||
$("#ad_banner-tab-content").children(".tab-pane").last().addClass("active");
|
$("#ad_banner-tab-content").children(".tab-pane").last().addClass("active");
|
||||||
|
|
||||||
|
<% if params[:action] && params[:action] =='create'%>
|
||||||
|
var trigger = $("#ad_banner-tab-content").children(".tab-pane").last().find(".preview_trigger");
|
||||||
|
new_url = trigger.attr("href").replace(/\/admin\/ad_banners\/.*\/preview/gi,"/admin/ad_banners/<%= @ad_banner.id %>/preview");
|
||||||
|
trigger.attr("href",new_url);
|
||||||
|
<% end %>
|
Reference in New Issue