javascript - ajax HTML content not rendering in bootstrap pop -
javascript - ajax HTML content not rendering in bootstrap pop -
i trying html content ajax request load in twitter bootstrap (v3) popover.
the popover element looks this.
<a class="more-info" data-remotecontent="/tasks/moreinfo/56eb0256-1a78-483c-b053-a387011f5b97" data-original-title="task 1" data-title="task 1" data-toggle="popover" rel="popover" href="/tasks/56eb0256-1a78-483c-b053-a387011f5b97">task 1</a>
and javascript looks this.
$('a.more-info').each(function () { var info = $(this); info.bind('mouseenter', function () { info.popover({ html: true, title: info.html(), content: 'loading', }).popover('show'); $.get(info.attr('data-remotecontent'), function (data) { }).done(function (data) { info.attr('data-html', 'true'); //info.popover({ content: data, placement: 'right' }).popover('show'); info.attr('data-placement', 'right'); info.attr('data-content', data); info.popover('show'); }); }); info.bind('mouseleave', function () { info.popover('hide'); }); });
the ajax request returns html never gets rendered popover. have feeling may not escaping response string properly.
what missing ajax response rendered content of popover?
in absence of bootstrap method of injecting new content popover
that's initialized, have manipulate generated markup shown below. this not ideal solution. recommend calling destroy
method 1 time once ajax content received updating element , initializing , programmatically opening popover.
a. manipulating popover markup -- not good
here how popover markup looks like:
<div class="popover fade right" role="tooltip" ....> <div class="arrow" style="top: 12.987012987013%;"></div> <h3 class="popover-title">task 1</h3> <div class="popover-content">loading</div> </div>
note: the main reason not solution there's no guarantee markup in future versions.
concept verification
b. calling destroy method, initializing , opening -- good
concept verification
in addition, mouseleave
handler have destroy popover 1 time again , initialize if want each mouseenter
event produce same loading ..
effect.
info.bind('mouseleave', function () { info.popover('destroy') .popover({ html: true, title: info.html(), content: 'loading', }); });
javascript jquery twitter-bootstrap
Comments
Post a Comment