Skip to content

Commit 7a88660

Browse files
author
Danny
committed
Fix: Reapplying of data to the subsequent elements with the same sub-template reference.
1 parent df64e3e commit 7a88660

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

jquery.template.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ $.fn.template = function(vars, inPlace) {
302302
$subtempl
303303
.each(function() {
304304
var $this = $(this);
305-
var matches = $this.attr('template').match(/^([{\[])(.*)[\]}]$/);
305+
var templateValue = $this.attr('template');
306+
var matches = templateValue.match(/^([{\[])(.*)[\]}]$/);
306307
var isObject = matches[1] == "{";
307308
var propName = matches[2];
308309
var subVars = vars[propName];
@@ -311,7 +312,7 @@ $.fn.template = function(vars, inPlace) {
311312

312313
// Remove clones
313314
$this
314-
.siblings('[template-clone]')
315+
.prevUntil(':not([template-clone="' + templateValue + '"])', '[template-clone="' + templateValue + '"]') /* only previous siblings as there can be multiple template="[abc]" elements with the same subelent so we need to know whose what */
315316
.filter(function() {return $(this).attr('template-clone') == $this.attr('template');})
316317
.remove();
317318

jquery.template.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)