0

次のツリー構築タブが動的にあります。タブには、ソースがjsonファイルから取得されたiframeがあります。

<script type="text/javascript"> 
$(function(){   
   $('#tree_menu').tree({    
   animate:true,    
    onClick: function open1(node){
      if ($('#tabs').tabs('exists',node.id)){
      $('#tabs').tabs('select', node.id); 
       } else {
        $('#tabs').tabs('add',{
        title: node.id,
        content: "<iframe id='superframe' frameborder='0' width='100%' scrolling='auto' height='99%' src='" + node.attributes.url + "'><iframe>",
        closable:true, 
        tools:[{  
         iconCls:'icon-mini-refresh',  
         handler:function(){  
           alert('refreshing'); 
        $('#superframe').get(0).contentWindow.location.reload();    
         }  
        }] 

        });
      }
    }
  });

  $('#tabs').tabs({
  onBeforeClose: function(title){
    return confirm('Are you sure you want to close ' + title);
    }
  });

});
</script>

私が達成したいのはタブアイコンです-ミニリフレッシュをクリックして、その特定のタブにiframeをリロードします。上記のコードでこれを行うことができますが、最初に開いたタブでのみ機能します。2番目から、それはもう機能していません。さわやかではありません....グーグルで見つかったすべての可能なiframeリロードメソッドを試しましたが、成功しませんでした。

これを手伝ってくれませんか。どうもありがとう!

4

1 に答える 1

2

これを実現するには、iframe の ID を一意にする必要があります。以下のコードを試してください。

 <script type="text/javascript"> 
$(function(){   
   $('#tree_menu').tree({    
   animate:true,    
    onClick: function open1(node){
      if ($('#tabs').tabs('exists',node.id)){
      $('#tabs').tabs('select', node.id); 
       } else {
        var frameId='superframe'+node.id;
        $('#tabs').tabs('add',{
        title: node.id,
        content: "<iframe id='"+frameId+"' frameborder='0' width='100%' scrolling='auto'     height='99%' src='" + node.attributes.url + "'><iframe>",
        closable:true, 
        tools:[{  
         iconCls:'icon-mini-refresh',  
         handler:function(){  
           alert('refreshing'); 
        $('#'+frameId).get(0).contentWindow.location.reload();    
         }  
        }] 

        });
      }
    }
  });

  $('#tabs').tabs({
  onBeforeClose: function(title){
   return confirm('Are you sure you want to close ' + title);
   }
 });

});
</script>
于 2013-02-25T05:34:26.710 に答える