Search code examples
jquerycolorbox

Unable to modify colorbox settings on onload trigger


I am trying to override default colorbox parameter withing onLoad event trigger:

 $(".iframe").colorbox  ({
    iframe:true,
    width: '80%',
    height: '80%',
    onLoad:function() {

        $.colorbox.settings = '40%';

    }
});

But colorbox does not use that setting, debuger shows that after event has been triggered - it used the initial setting and my modification appears to be some kind of default parameters copy. Calculations for width ignore my new setting and the initial value is being used...

How do I access settings properties of the colorbox object I am currently working with?


Solution

  • I've checked the sources at http://www.jacklmoore.com/colorbox/jquery.colorbox.js and managed to hack this together:

    $(".iframe").colorbox  ({
        iframe:true,
        width: '100%',
        height: '100%',
        onLoad:function() {
    
            var d = $(this).data('colorbox');
            d.width = '20%';
            $(this).data('colorbox',d);
        }
    });
    

    I hope this helps.