easyui tab 加載iframe 高度問題

其實按網上搜的結果,easyui 有個data-options屬性是fit:true. 加上他以後會使得自適應父類的寬高。html

加上以後,發現個問題,當刷新tab內容的時候高度是對的,可是新建tab的時候高度仍是沒自適應。下面解決辦法是,新建以後再update下當前選中的tab.簡單暴力。立竿見影:ui

// 新建tab
function open1(plugin,route){
    if ($('#tt').tabs('exists',plugin)){
        $('#tt').tabs('select', plugin);
        // tab刷新內容
        var tab = $('#tt').tabs('getSelected');
        $("#tt").tabs('update', {
            tab: tab,
            options: {
                title: plugin,
                content: '<iframe scrolling="auto" frameborder="0"  src="'+route+'" style="width:100%;height:100%;"></iframe>',
                closable: true,
                selected:true
            }
        });
    } else {
        //var content = '<iframe scrolling="auto" frameborder="0"  src="'+route+'" style="width:100%;height:100%;"></iframe>';

        $('#tt').tabs('add',{});

        // tab刷新內容 fix 自適應高度
        var tab = $('#tt').tabs('getSelected');
        $("#tt").tabs('update', {
            tab: tab,
            options: {
                title: plugin,
                content: '<iframe scrolling="auto" frameborder="0"  src="'+route+'" style="width:100%;height:100%;"></iframe>',
                closable: true,
                selected:true
            }
        });
    }
}  

以後又發現,在iframe右側總出兩個滾條。網上搜了個這個解決辦法。加上以後 果真就剩下一個iframe本身的滾條了。spa

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
相關文章
相關標籤/搜索