I am trying to get data from a resource using jquery ajax, and then I am trying to use this data to populate a popup, for example:
$('.myclass').popover({"trigger": "manual", "html":"true"}); $('.myclass').click(get_data_for_popover_and_display);
and function for receiving data:
get_data_for_popover_and_display = function() { var _data = $(this).attr('alt'); $.ajax({ type: 'GET', url: '/myresource', data: _data, dataType: 'html', success: function(data) { $(this).attr('data-content', data); $(this).popover('show'); } }); }
What happens is that the popover is not displayed when I click, but if I visit the item later, it will display a popover, but without content ( data-content attribute). If I put alert() in the success callback, it will display the returned data.
Any idea why this is happening? Thank!
javascript jquery twitter-bootstrap
licorna Nov 09 '11 at 15:31 2011-11-09 15:31
source share