Ceejay
Ceejay

Reputation: 7267

How can i change the popover data-placement in jquery

I am trying to change the bootstrap popover data-placement from bottom to left in jquery based on screen width.

<img src="images/user.svg" id="usericon" data-toggle="popover" data-placement="bottom" data-content="">

Jquery:

if ($(window).width() < 480) {
    $('[data-toggle="popover"]').popover({content: htmlcont,data-placement: left, html: true});
    } else {
    $('[data-toggle="popover"]').popover({content: htmlcont, html: true});
    }

not working for me...how can i do this?

Upvotes: 0

Views: 1180

Answers (1)

AmmarCSE
AmmarCSE

Reputation: 30557

Use placement instead of data-placement

if ($(window).width() < 480) {
    $('[data-toggle="popover"]').popover({content: htmlcont,placement: left, html: true});
    } else {
    $('[data-toggle="popover"]').popover({content: htmlcont, html: true});
    }

That is the property name they use for the options

Also, see Changing the position of Bootstrap popovers based on the popover's X position in relation to window edge?

Upvotes: 2

Related Questions