简体   繁体   中英

Bootstrap popover content via Ajax

i have a next code about popover, it works fine with content, but popovers doesn't create. is all ok with this code?

$.ajax({
        url: url,
        type: 'POST',
        data: data,
        dataType: 'html',
        success: function(answer) {
            $(element).popover({
                container: 'body',
                html: true,
                content: function (answer) {
                    return answer;
                }
            });
            $(element).popover('show')
        },
    })

element is A tag. and answer is html as string. When it comes to popover part looks like nothing happens.

You should set value to content directly. Not a function.

$.ajax({
        url: url,
        type: 'POST',
        data: data,
        dataType: 'html',
        success: function(answer) {
            $(element).popover({
                container: 'body',
                html: true,
                content: answer
            });
            $(element).popover('show')
        },
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM