weixin_33704591 2017-06-09 04:55 采纳率: 0%
浏览 118

切换popover(); 使用ajax

How to toggle popover of the same element? im using ajax so im using this to refer to its specific identity, when ajax success it will toggle its own popover i took this code from w3schools and use it in mine.

HTML

<input type = "text" id = "input_name" class="form-control" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover">

jQuery

$(document).on('keyup', '#input_name', function(){
    var myname = $(this).val();

    if(myname != ''){
        $.ajax({
            url:"sample.php",
            method: "POST",
            data:{myname:myname},
            dataType:"text",
            success:function(data){
                $("[data-toggle='popover']").popover(); 
            }
        });
    }

I want to call its own popover.

  • 写回答

1条回答 默认 最新

  • 衫裤跑路 2017-06-09 06:53
    关注

    https://jsfiddle.net/ws5zojyc/3/

    see above link it might help you

    $(function() {
        $("#input_name").popover({
            content: "Enter a text here"
        });
    });
    
    $("#input_name").keyup(function(event) {
        var myname = $(this).val();
        // alert(myname);
        if (myname != '') {
            $.ajax({
                url: "/echo/js/?js=" + myname,
                method: "POST",
                data: {
                    myname: myname
                },
                dataType: "text",
                success: function(data) {
                    $('#input_name').data('bs.popover').tip().find(".popover-content").html(data)
                }
            });
        }
    });
    

    you can use effect like hover , click etc.

    评论

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题