Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeff 21 posts 42 karma points
    Mar 27, 2012 @ 17:19
    Jeff
    0

    Fancybox iframe sizing

    Hello: 

    I am trying to automatically set the width and height of the fancybox iframe to numbers inputted by user. Below is my code: 

    <script type="text/javascript"> 
    $(function () { 
              $(".iframe").fancybox({ 
                  'width' : $(this).attr('width'), 
                  'height' : $(this).attr('height') 
                }); 
            }); 
    </script> 

    <ul> 
               foreach(var video in mainVideos) 
               { 
                  <li><a href="@video.videoUrl" class="iframe" width="@video.Width" height="@video.Height"></li> 
               } 
    </ul> 

    I realize that "width" and "height" has no meaning for anchors, but in this case, I'm just using them as attributes to hold numbers. For some reason, in the javascript, if I replace the attributes with the actual numbers, it works fine. But once I start using jquery to reference the dimensions, it does not read it. I know the numbers exist though, because when I alert($ (this).attr('height') ), it shows up. 

    Any help with this matter would be greatly appreciated. 

    Thank you for your time. 

    Sincerely, 

    Jeff

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 28, 2012 @ 06:50
    Jeroen Breuer
    0

    Don't know a lot about jQuery. Could you post your example with hard coded values that works? Maybe I can see what's different. I used this a while back in Umbraco 5 for the Modal:

    // popup buttons
    $("#submit_Popup").click(function(e) {
        e.preventDefault();
    
        var width = $(parent.window).width() - 140;
        var height =  $(parent.window).height() - 100;
    
        // Show tree modal window
        $u.Sys.WindowManager.getInstance().showModal({
            title: "Choose",
            isGlobal: true,
            forceContentInIFrame: false,
            modalStyle: "width:" + width + "px;height:" + height + "px;",
            content: "#popup-section-dialog",
            removeOnHide: false
        });
    
    });

    Not the same but perhaps it can help you.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft