0
votes

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?

1
I know you accepted an answer but I am still wondering - 1: why should you have a button inside an anchor; 2: how do you call the function launchCont() (and pass the parameter rid) ?JFK
Not sure why i had the button in there. I think I copied from a working example. If I find the link again, I will post it here. I launch from an 'onclientclick' event from a server-side linkbutton (I pass the value from the db to rid that way)Andrew

1 Answers

0
votes

remove the first fancybox() method and the redundant spaces:

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