0
我有引導模態這裏有一個問題,所以在我的應用程序的後端我從SQL拉出來的數據,我所說的JS函數是這樣的:添加數據來引導模式
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowPopup",
"MailLanguageChange('" + Description + "','" + TextResult + "');", true);
和JS看起來是這樣的:
function MailLanguageChange(Name, Text) {
$('#MainContent_NewMailTemplate').modal('show');
document.getElementById("Upper_txtDesc").value = Name;
document.getElementById("TextEditorTextArea").innerHTML = Text;
}
所以螢火命中,在此功能突破點,所以我的函數肯定調用的工作,但來這裏的問題,JS正試圖把這些數據應用於到模式,所有元素之前的模態被加載。
但是,當我使用這種模式的多個purpuses ...有反正寫下來,「不要做任何事情,直到顯示模態」?
$('#MainContent_NewMailTemplate').modal('show');
正如文檔所述,在實際顯示模態之前,它會返回給調用者......我怎麼能通過這個?
編輯:
這是我怎麼也嘗試過
function MailLanguageChange(Name, Text) {
$('#MainContent_NewMailTemplate').modal('show');
$("#MainContent_NewMailTemplate").on('shown.bs.modal', function() {
document.getElementById("Upper_txtDesc").value = Name;
document.getElementById("TextEditorTextArea").innerHTML = Text;
});
}
結論:
隨着使用全局變量的邏輯由@Guruprasad饒 我結束提供只需簡單地使用
$(document).ready(function() {
document.getElementById("Upper_txtDesc").value = name;
document.getElementById("TextEditorTextArea").innerHTML = text;
});
謝謝
我看到的,但由於某種原因,螢火蟲也沒有這麼函數內..這是我的問題 – Veljko89
你能告訴我們您如何使用它,什麼實際情況?你是否通過'ajax'查看包含'modal'負載? –
我編輯的問題,而不是在這裏使用AJAX,只是在我的C#頁面回發後調用JS函數 – Veljko89