2011-12-05 133 views
2

我想單擊ZK的borderlayout(可摺疊「East」或「North」或...)以使用javascript臨時打開它。 我該怎麼辦?使用javascript展開/摺疊zk面板

提前感謝好友。

UPDATE:

當它是封閉的,通過點擊關閉邊境(不打開ICON(看畫面中的光標的位置)這將是暫時打開。我想要一個封閉的borderLayout並用javascript/jquery打開它。

圖片: enter image description here

+0

我想萬英鎊,但是這是我們所可能發生有人正從你的接受的答案。 –

+0

@RoryMcCrossan我查了一下,他已經接受了答案,答案已經接受! :) –

回答

1

你的目的,在這裏我提供了另外一個例子。 http://zkfiddle.org/sample/bk3jop/2-Close-border-layout-panel-by-javascript

<script> 
    function openNorth(){ 
     var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 

     if(!widget.isOpen()){ 
     try{ 
      widget.doClick_({ 
      domTarget:widget.$n('colled') 
      }); 
     }catch(e){ //ignore unhandled exception. 
     } 
     } 

    }  
    </script>   

無論如何,它更像是一個黑客。

有關詳細信息,你可以參考 https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/layout/LayoutRegion.js

doClick_: function (evt) { 
     var target = evt.domTarget; 
     switch (target) { 
     case this.$n('btn'): 
     case this.$n('btned'): 
     case this.$n('splitbtn'): 
      if (this._isSlide || zk.animating()) return; 
      if (this.$n('btned') == target) { 
       var s = this.$n('real').style; 
       s.visibility = "hidden"; 
       s.display = ""; 
       this._syncSize(true); 
       s.visibility = ""; 
       s.display = "none"; 
      } 
      this.setOpen(!this._open); 
      break; 
     case this.$n('colled'):     
      if (this._isSlide) return; 
      this._isSlide = true; 
      var real = this.$n('real'), 
       s = real.style; 
      s.visibility = "hidden"; 
      s.display = ""; 
      this._syncSize(); 
      this._original = [s.left, s.top]; 
      this._alignTo(); 
      s.zIndex = 100; 

      if (this.$n('btn')) 
       this.$n('btn').style.display = "none"; 
      s.visibility = ""; 
      s.display = "none"; 
      zk(real).slideDown(this, { 
       anchor: this.sanchor, 
       afterAnima: this.$class.afterSlideDown 
      }); 
      break; 
     } 
     this.$supers('doClick_', arguments);   
    }, 
2

1.Get從ZK客戶端引擎的部件。

2.call就是setOpen(true)還是就是setOpen(假)

下面是這個樣本,也你可以測試它ZK小提琴平臺。

http://zkfiddle.org/sample/bk3jop/1-Close-border-layout-panel-by-javascript

<zk xmlns:w="client"> 

    <script> 
    function closeNorth(){ 
     var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 
     widget.setOpen(false); 

    } 
    function openNorth(){ 
     var widget = zk.Widget.$("$mynorth"); //Using the pattern for $ + ID to select a ZK widget. 
     widget.setOpen(true); 

    }  
    </script> 
    <button label="click me to close it" w:onClick="closeNorth();" />   
    <button label="click me to open it" w:onClick="openNorth();" />  

    <borderlayout > 
    <north id="mynorth" title="North" maxsize="300" size="50%" splittable="true" collapsible="true"> 
      <div> 
      Test .... <textbox /> 
      </div> 
    </north> 
    </borderlayout> 

</zk> 
+0

感謝哥們,但我想暫時打開它。當我們點擊封閉的邊界區域(不是圓圈ICON)(當它關閉時),它會暫時打開它,當我們點擊borderlayout的外部時,它會自動關閉。 –

+0

你能否更清楚地解釋你的用例,我相信我們可以做你想要的大多數情況。但首先,我必須知道你想要做什麼。 :) – TonyQ

+0

我更新了問題好友;) –