2

Let me preface this by saying the answer to my question is most likely not the most ideal solution to my problem but it seems to me to be the fastest solution. At a later stage i may revisit this issue and properly solve it.

I have a Datatable with the YADFC plugin which is behaving weirdly.

On refresh of the page, the headers are misaligned wrt the columns as below:

enter image description here

If i resize my window even by the smallest amount, the headers are recalculated and snap in the correct position as below:

enter image description here

Is there any way to programmatically trigger a small window resize event?

Update: Solved using $(window).trigger('resize');

nluigi
  • 1,263
  • 2
  • 15
  • 35
  • Here is an answer - http://stackoverflow.com/questions/1861109/forcing-windows-resize-to-fire – Pugazh Feb 02 '17 at 08:43

1 Answers1

2

try this

    $(window).resize(function() {
        setTimeout(function() {
            resize();
        })
    })
Saurabh Agrawal
  • 7,581
  • 2
  • 27
  • 51
  • Can you indicate what is the difference between your answer and `$(window).trigger('resize');` which i ended up using? – nluigi Feb 02 '17 at 08:50
  • @nluigi just go through this link you will find the difference between `$(window).trigger('resize');` and `$(window).resize(function(){})` http://stackoverflow.com/questions/36777631/passing-parameters-to-window-onresize-when-using-triggerresize – Saurabh Agrawal Feb 02 '17 at 08:56