easyuiのtabに取得するiframeメソッド

3111 ワード

easyuiのtabを使用する場合、tabヘッダをクリックするたびに、そのtabの下のiframeの内容を動的にリフレッシュする必要がある場合があります.
tabのhtmlは以下の通りです.
Htmlコード:
<div id="tab-user-right" >   
        <div title="         " id="user-right-act">             
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="     " id="user-role">              
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="        " id="user-right-role">             
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="      " id="user-right-all">            
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="    -  " id="user-right-org">           
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="    -  " id="user-right-dept">              
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
    </div>

動的リフレッシュのjsは次のとおりです.
//          
        var reload="T";  
        $(function(){  
            $('#tab-user-right').tabs({   
                onSelect: function(){  
                    openTab();                                        
                }  
            });  
        });  
          
        function openTab(){           
            var tab = $('#tab-user-right').tabs('getSelected');  
            var tbId = tab.attr("id");  
            //  tab iframe    
            var tbIframe = $("#"+tbId+" iframe:first-child");  
            if(reload=="T"){                  
                tbIframe.attr("src",tbId+'.action?userId='+userId);  
            }else{        
                if( tbIframe.attr("src")==""){  
                  tbIframe.attr("src",tbId+'.action?userId='+userId);  
                }  
            }  
        }

コードに注意:
Jsコード
  • var tab = $('#tab-user-right').tabs('getSelected');  
  •             var tbId = tab.attr("id");  
  • //tabのiframeオブジェクトを取得
  •             var tbIframe = $("#"+tbId+" iframe:first-child");