0

Ok, I have used fancybox already with some success, but I was wondering if I could pass a value for the href? I've kinda put a clunky solution together, but the box tells me " The requested content cannot be loaded. Please try again later." What I've done is created a separate function to trigger the launch of the fancybox....

First here's the html of the iframe/fancybox element (which as a tiny button the user cannot see):

Here's my code:

<a id="link2" href="ContentPage.aspx"><input id="Btn1" type="button" value="GetContent" class="smallBtnCls" /></a>

..and the javascript:

function launchCont(rid){
        var lnk = 'ContentPage.aspx ?act=Add&id=' + rid;
        $('#link2').attr('href',lnk);

        //alert($('#link2').attr('href'));
        $("#Btn1").fancybox().trigger('click');
    } 

and the fancy box config is:

  $("#Btn1").click(function() {
    $("#link2").fancybox({
        'width': '55%',
        'height': '45%',
        'autoScale': false,
        'modal': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'type': 'iframe',
        onStart: function() {
            //return window.confirm('Continue?');
            $.fancybox.showActivity();
        },
        onCancel: function() {
            //alert('Canceled!');
        },
        onComplete: function() {
            //alert('Completed!');
            $.fancybox.hideActivity();
        },
        onCleanup: function() {
            //return window.confirm('Close?');
        },
        onClosed: function() {
            //alert('Closed!'); 
        }
    });


});

Any Ideas???? Or am I looking at it the wrong way?

4

1 に答える 1

0

fancybox()最初の方法と冗長スペースを削除します。

function launchCont(rid){
    var lnk = 'ContentPage.aspx?act=Add&id=' + rid;
    $('#link2').attr('href',lnk);
    $("#Btn1").trigger('click');
} 
于 2012-07-11T23:14:34.637 に答える