Permalink
Browse files

fix content lost when multi trigger with same content

  • Loading branch information...
1 parent 26aa6dc commit 155b62b8d1d13fc4572fd7f15efd9e85065c136c @sandywalker committed Jan 8, 2016
Showing with 40 additions and 9 deletions.
  1. +2 −1 ROADMAP.md
  2. +32 −3 demo/test.html
  3. +0 −2 dist/jquery.webui-popover.js
  4. +6 −3 src/jquery.webui-popover.js
View
@@ -3,4 +3,5 @@
* Optimize the display on mobile device
* Add fit width/height to some container
-* Nested popover support
+* Nested popover support
+* unique option for performer optimize when huge number of the popovers in same page.
View
@@ -61,6 +61,17 @@
</head>
<body>
+
+ <div class="myLink">
+<a href="#" class="trigger">trigger 1</a>
+<a href="#" class="trigger">trigger 2</a>
+<a href="#" class="trigger">trigger 3</a>
+<a href="#" class="trigger">trigger 4</a>
+</div>
+<div id="myPopup">
+<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
+</div>
+
<div style="text-align:center">
<a href="#" class="border-pos pull-left" data-placement="right-bottom">a <br /> a <br /> </a>
<a href="#" class="border-pos" data-placement="">aa</a>
@@ -87,7 +98,7 @@
<h1>Hi there</h1>
<p>This is next element <a href="#" id="linkInPop" class="link-in-pop">clickMe</a> </p>
</div>
-
+ <a id="hidePop" href="#">hide</a>
<a href="#" class="popByUrl" data-url="#url1" >Pop by url1 </a>
<a href="#" class="popByUrl" data-url="#url2">Pop by url1 </a>
@@ -125,7 +136,9 @@
</div>
</div>
- <p>&nbsp;</p>
+ <p>
+ <a href="#" class="inline-content" data-content="<span>aaaa </span><span>aaaa </span><span>aaaa </span><span>aaaa </span><span>aaaa </span><span>aaaa </span><span>aaaa </span>">inline-content</a>
+ </p>
<p>&nbsp;</p>
@@ -3763,6 +3776,10 @@
<script type="text/javascript">
$(document).ready(function(){
+
+ $('.trigger').webuiPopover({url:'#myPopup'});
+
+
$('#popover_test').webuiPopover({
constrains: 'horizontal',
trigger:'click',
@@ -3893,7 +3910,13 @@
//alert(1);
});
- $('#popNext').webuiPopover({trigger:'hover',animation:'pop','closeable':true});
+ $('#popNext').webuiPopover({trigger:'hover',animation:'pop','closeable':true}).webuiPopover('show');
+
+ $('#hidePop').on('click',function(e){
+ e.preventDefault();
+ $('#popNext').webuiPopover('hide');
+ });
+
$('#popInline').webuiPopover({trigger:'hover',animation:'pop'});
$('#popById').webuiPopover({url:'#idContent',cache:false});
@@ -3922,6 +3945,12 @@
$('#arrowPos').webuiPopover();
$('.manyPops').webuiPopover({animation:'pop'});
+
+ $('.inline-content').webuiPopover({
+ placement:'auto-top',
+ width:150,
+ height:50
+ });
});
</script>
@@ -256,8 +256,6 @@
$target = this.getTarget().removeClass().addClass(pluginClass).addClass(this._customTargetClass);
if (!this.options.multi) {
this.hideAll();
-
-
}
if (this._opened) {
return;
@@ -248,8 +248,6 @@
$target = this.getTarget().removeClass().addClass(pluginClass).addClass(this._customTargetClass);
if (!this.options.multi) {
this.hideAll();
-
-
}
if (this._opened) {
return;
@@ -561,7 +559,12 @@
} else if (content instanceof jQuery) {
content.removeClass(pluginClass + '-content');
$ct.html('');
- content.appendTo($ct);
+ //Don't want to clone too many times.
+ if (this.options.cache){
+ content.clone(true,true).appendTo($ct);
+ }else{
+ content.appendTo($ct);
+ }
}
this.$target = $target;
},

0 comments on commit 155b62b

Please sign in to comment.