2

I have a fancy set up at the top of document.ready that looks like this:

$('.fancyBox').fancybox({
            'type': 'iframe',
            'closeBtn': false,
            'overlayShow' : true
        });

Afterwards I'm checking a value on the page and simulating a click fi its true

            if ($('#fromLogin').val() == "True") {
            $('a#fancyLink').trigger('click');
        }

Everything works fine but except the overlay doesn't show up. When I click the link manually it works fine though. What could I be missing?

EDIT: The relevant HTML posted below for the parent.

<input type="hidden" id="fromLogin" value= "@ViewBag.FromLogin" />
<a href="../Account/AccountOverview" id="fancyLink" class="fancyBox" style="display: block;">Click</a>

<div id="account_settings">
@Html.ActionLink("Update Account Settings", "Manage", "Account")
</div>
<div id="main_wide"> .... </div>
4

1 回答 1

1

尝试包装触发点击的代码部分,如下所示:

$(document).ready(function (e) {
   if ($('#fromLogin').val() == "True") {
      $('a#fancyLink').trigger('click');
   }
});  
于 2017-07-30T02:17:54.150 回答