문제

Does anyone know the JavaScript for setting display:none on an empty web part zone? I remember seeing it once on a publishing site but now can't find it.

This is to avoid the padding and spacing a web part zone displays when there is no web part added to it.

도움이 되었습니까?

해결책

WSS 3 web part pages has TD's containing the WebPartZones and those TD's have a name and id which is _invisibleIfEmpty. Then each page contains a javascript like this:

<script language="javascript">if(typeof(MSOLayout_MakeInvisibleIfEmpty) == "function") {MSOLayout_MakeInvisibleIfEmpty();}</script>

The MSOLayout_MakeInvisibleIfEmpty function makes them invisible...

/WW

다른 팁

Or, as SharePoint Publishing Page Layout puts it:

<SharePointWebControls:ScriptBlock runat="server">
if(typeof(MSOLayout_MakeInvisibleIfEmpty) == &quot;function&quot;) 
{MSOLayout_MakeInvisibleIfEmpty();}</SharePointWebControls:ScriptBlock>

Somehow, MSOLayout_... did not work out for me, so I wrote the following jQuery code which works as well and also checks if there is only a menu inside that cell before it hides it.

$('[name="_invisibleIfEmpty"]').filter(function () {
    return $.trim($(this).html()).length == 0 || $(this).children("menu").length;
}).hide();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top