Search code examples
inputbootstrap-4tooltippopover

Bootstrap input field inside tooltip popover removed from output html


Hello i`m using boostrap 4.3.1 and included popper 1.14.7.

Normally I can add input fields in the content of the popup/tooltip. I don`t since when, but at the moment when I put input field in the content then only the text is visible.

When I look in the source (compiled html) I can see that popper or bootstrap removed the input fields. Do I something wrong?

    var options = {
        html: true,
        // content: function(){ return $(".amountElec.popup").html();},
        placement: "bottom",
        container: "body"
    };
    
    $(function(){
        $('#manualinput').popover(options);
    })
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>


<div id="manualinput" 
     data-container="body" 
     data-toggle="popover"  
     data-content="test <input name='test' type='text' value='2'>" 
     data-html="true" 
     data-placement="bottom">
     
     OPEN TOOLTUP
</div>


Solution

  • I found the solution...

    I my case add this to the javascript:

            var myDefaultWhiteList = $.fn.tooltip.Constructor.Default.whiteList;
            myDefaultWhiteList.input = [];

    https://getbootstrap.com/docs/4.3/getting-started/javascript/#sanitizer