次のことをするボタンがあります:クリックするとモーダルポップアップが開きます。 モーダルポップアップには別のボタンがあり、クリックすると2つのテキストボックスと2つのボタンが表示されます。私が望むのは、閉じるか単に閉じるモーダルをクリックすると、2つのラベルと追加ボタンを含む前の状態にしたいということです。ブートストラップ閉じる後のモーダルリフレッシュ
これらは私のjavascriptのコードです:
//this shows the additional textboxes and buttons
$("#toggle").click(function()
{
$("#content").toggle("slow");
$("#divButtons").toggle();
$("#toggle").hide();
});
//this is where i tried to refresh the modal back to its original state
$(function() {
$(document).on("hidden.bs.modal", "#exampleModal", function() {
$(this).find("#content").remove(); // Remove from DOM.
$(this).find("#divButtons").remove();
$("#toggle").show();
$(this).find("#portValue").html("");
$(this).find("#hostValue").html("");
});
});
これは私がこれまでにやっていることです:Demo
私のコードの問題は、私は、モーダルを閉じたときに、クリックしていることです追加ボタンをもう一度押すとボタンが削除され、2つのテキストボックスと2つのボタンは表示されません。
これは、 '$(this)).find(" content ")。remove();' inside '" hidden.bs.modal "'イベントを使ってDOMから '#content ' 。したがって、次回に「新しいボタンを追加」をクリックすると、もう存在しないため表示する「#コンテンツ」はありません。 –