2017-07-26 15 views
0

コンテンツを動的に作成し、そのオプションと対話したいポップオーバーを実行しようとしています。ダイナミック内のブートストラップポップオーバー選択オプション

私は私のoptionselect、もう1つは「受け入れ」とbuttonsを「キャンセル」を使用してフォームを持っているpopoverをポップアップしていています。しかし、まず第一に私のページには表示されず、2番目のもの(w3schoolsエディタで最後に私がポップオーバーを表示できるところにしようとしています)のキャンセルボタンは現在のポップオーバーを隠しません。

これは

(今だけそれが「こんにちは」が表示しようとするにconsole.logを持っていますが、動作しません)作業が、閉じていないポップオーバーのためJsFiddleであり、これはしようとして用jsFiddleです'No Disponible'が選択されているときにポップオーバーを取得します。

誰も私の試みがうまくいかない理由を説明できますか?

答えて

1

ここでは、前半の解決策としてhttps://jsfiddle.net/c3yq1o43/3/を使用します。それはが、私は質問の後半をしようとしてボタン

$(document).ready(function(){ 
 

 
\t closepop = function(){ 
 
    \t $('[data-toggle="popover"]').popover('hide'); 
 
    } 
 
     
 
    var pop = $('[data-toggle="popover"]').popover({ 
 
    html:true, 
 
    content: function(){ 
 
    \t return "<form name='statusForm'>"+ 
 
     \t \t \t "<div class='form-group'>"+ 
 
        \t "<textarea class='form-control' name='estado' placeholder='Motivo de la no-disponibilidad' required></textarea>"+ 
 
        "</div>"+ 
 
     \t \t \t "<button class='button btn btn-success' type='button'>Aceptar</button>"+ 
 
        "<button class='button btn btn-success' type='button' onclick='closepop()'>Cancelar</button>"+ 
 
       "</form>" 
 
    }}); 
 
    
 
    
 
    
 
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 

 
<body> 
 
    <div class="container"> 
 
    <h3>Popover Example</h3> 
 
    <p>Popovers are not CSS-only plugins, and must therefore be initialized with jQuery: select the specified element and call the popover() method.</p> 
 
    <a href="#" data-toggle="popover" title="Popover Header">Toggle popover</a> 
 
    </div> 
 
</body>

をキャンセル]をクリックポップオーバーを閉じるです。 ちょっと混乱...

[いいえディスポーザブル]オプションを選択した場合、のポップオーバーを表示しますか?

+0

ありがとうございます!はい、これは次のようなものです:http://jsfiddle.net/xrkxdedg/3/「いいえ、いいえ」をクリックするとフォームが表示され、Cancelを押すと閉じます – UnsignedFoo

+0

申し訳ありませんが間違っていました。私は "無意味な"と**をクリックしないで**をクリックしたいと思います。 – UnsignedFoo

関連する問題