2017-06-11 43 views
0

我動態地將頁面加載到另一頁面。 當我加載頁面時,除輸入字段外,所有項目都採用正確的CSS自定義。我使用MDL,但我也嘗試過使用Bootstrap,但問題仍然存在。Jquery onLoad() - 加載的頁面中的輸入字段顯示不正確

顯示在頁面1:enter image description here

在顯示第2頁:enter image description here

mainLayout.load(url, function(responseTxt, statusTxt, xhr) {   
    // Load the javascript associated to this html page 
    if(script_path !== undefined) { 
     $.getScript(script_path); 
    } 
}); 

我使用相同的代碼對輸入字段中的第一頁,並在加載頁。

<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> 
    <input class="mdl-textfield__input" type="text" id="input_new_tr_value" /> 
    <label class="mdl-textfield__label" for="input_new_tr_value">{{ _('value') }}</label> 
    <span class="mdl-textfield__error">{{ _('error') }}</span> 
    </div> 

有什麼建議嗎? 所有其他元素都以正確的方式顯示。 我也嘗試在頁面2加載後用getScript()和CSS文件重新加載MDL js文件。

回答

0

我已經找到了解決辦法:

只需撥打 「componentHandler.upgradeDom();」來自JavaScript文件。

相關問題