Merge pull request #13165 from stefanneculai/master

Fix popover when using append
This commit is contained in:
Jacob 2014-03-24 22:42:40 -04:00
commit b3421cf040
2 changed files with 30 additions and 1 deletions

View File

@ -44,7 +44,7 @@
var content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
$tip.find('.popover-content')[ // we use append for html objects to maintain js events
$tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
](content)

View File

@ -61,6 +61,35 @@ $(function () {
$('#qunit-fixture').empty()
})
test('should not duplicate HTML object', function () {
$.support.transition = false
$div = $('<div>').html('loves writing tests (╯°□°)╯︵ ┻━┻')
var popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-fixture')
.popover({
content: function () {
return $div
}
})
popover.popover('show')
ok($('.popover').length, 'popover was inserted')
equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
popover.popover('hide')
ok(!$('.popover').length, 'popover was removed')
popover.popover('show')
ok($('.popover').length, 'popover was inserted')
equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
popover.popover('hide')
ok(!$('.popover').length, 'popover was removed')
$('#qunit-fixture').empty()
})
test('should get title and content from attributes', function () {
$.support.transition = false
var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')