google-gadget

Dynamic Height Adjusting w/ Open Social Gadget


I have a gadget that is a glossary with a number of different pages. users can upload new words to the data source and those words will be pulled into the glossary through an AJAX call.

I want to resize the gadget window everytime the window is re-sized OR a new letter is selected and the page height changes (ie the gadget html block height).

Google developers has posted this on their website. However, this clearly is not working for me. The scrolling is not registering on the iframe and the height is not adjusting when the window is resized.

Here are my ModulePrefs

title="Climate Policy and Science Glossary"
  description="Paragraph format"
  height="300"
  scrolling="true">
<Require feature="dynamic-height"/>
<Require feature="opensocial-0.8" />

Here is the gadget's script telling it to adjust:

    window.onresize = adjust;
    function adjust() {
        var wndwH = gadgets.window.getViewportDimensions().height, 
            wgtH = $('#_glossary').closest('html').height,
            h = Math.min(wndwH, wgtH);
       gadgets.window.adjustHeight(h);
    }
    gadgets.util.registerOnLoadHandler(adjust);

What's going on? Am I doing something wrong or is there anyone else out there having trouble with Google's dynamic height??


Solution

  • The adjust function really only needs:

    function adjust() {
       gadgets.window.adjustHeight();
    }
    

    That should fit everything automatically.