Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change thickbox popup size dynamically

I'm using ThickBox to open popup in my page. In popup there is a tab on click on which i need to change the size of ThickBox popup window. How can i do that ?

Thanks in advance.

like image 451
MUS Avatar asked Jul 14 '11 20:07

MUS


1 Answers

This is the code they use

$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
    if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
        $("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
    }

so you can use the same with a slight change (assuming you use a modern version of jQuery)..

$('#yourbutton').click(function() {
    var TB_WIDTH = 100,
        TB_HEIGHT = 100; // set the new width and height dimensions here..
    $("#TB_window").animate({
        marginLeft: '-' + parseInt((TB_WIDTH / 2), 10) + 'px',
        width: TB_WIDTH + 'px',
        height: TB_HEIGHT + 'px',
        marginTop: '-' + parseInt((TB_HEIGHT / 2), 10) + 'px'
    });
});

Demo at http://jsfiddle.net/gaby/rrH8q/

like image 152
Gabriele Petrioli Avatar answered Nov 09 '22 06:11

Gabriele Petrioli