我有 2 个链接到 Ruby on Rails 上的 Fancyboxes:
链接 1 的课程是:“why_am_i_here fancybox” 链接 2 的课程是:“feedback_link fancybox”
当我第一次单击链接 1 时,我需要链接 2 的幻想框。如果我再次单击,它会将我带到正确的链接。另一个按钮(链接 2)正常工作。
与其用各种可能/可能不相关的代码侵入你,不如告诉我你需要什么进一步的信息,我会提供。
这是为why_am_i_here渲染的HTML(链接1):
$(function(){
var search_value;
$(".why_am_i_here_button, .fancybox").fancybox({
type : 'iframe',
autoSize : true,
afterLoad : function(){
$(".fancybox-iframe").contents().find(".feedback_link").remove();
$(".fancybox-iframe").contents().find("#app_header_right").remove();
$(".fancybox-iframe").contents().find("#feed").remove();
$(".fancybox-iframe").contents().find("#search_submit").unbind("type");
block_off_default_clicks();
set_click_listeners();
$(".fancybox-iframe").contents().find("#search_submit").click(function(e){
e.preventDefault();
parent.$.fancybox.close();
});
},
beforeClose : function(){
search_value = $(".fancybox-iframe").contents().find('#search').val();
},
afterClose : function(){
if (search_value){
$("#searchbox_holder").html("<%= escape_javascript(render 'restaurants/searchbox') %>");
$("#search").attr("value", search_value);
$("#user_edit_wrapper").hide();
$(".search_form").submit();
}
}
}).eq(0).click().stopPropagation();
});
这是为 feedback_link 渲染的 HTML(链接 2):
$(function(){
$(".feedback_link, .fancybox").fancybox({
type : 'iframe',
afterLoad : function(){
$(".fancybox-iframe").contents().find(".feedback_link").remove();
$(".fancybox-iframe").contents().find("#feed").remove();
$(".fancybox-iframe").contents().find("#app_header_right").remove();
block_off_default_clicks();
$(".fancybox-iframe").contents().find(".feedback_form").submit(function(e){
parent.$.fancybox.close();
});
}
}).eq(0).click().stopPropagation();
});
这是每个链接的 HTML:
链接1:
<div id = "why_am_i_here_container">
<%= link_to "Here\'s how it works", info_path(:welcome => params[:welcome]), :remote => true, :class => "why_am_i_here_button fancybox rounded-corner", :id => "why_am_i_here" %></div>
链接2:
<li class = "app_header_item"><%= link_to 'Feedback (please)', new_feedback_path, :remote => true, :class => "feedback_link fancybox", :id => "feedback_link" %></li>