Skip to content

Commit 1823add

Browse files
committed
Updates to jquery.loadTemplate-1.4.3.js
As per my two issue submissions: 1) Modified getValue to accommodate null values during data binding 2) Modified the nestedTemplateFormatter to only return the generated child nodes if the parentElement is not specified.
1 parent 10e535a commit 1823add

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

jquery-loadTemplate/jquery.loadTemplate-1.4.3.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@
471471
part,
472472
value = data;
473473

474-
while ((part = paramParts.shift()) && typeof value !== "undefined") {
474+
while ((part = paramParts.shift()) && typeof value !== "undefined" && value != null) {
475475
value = value[part];
476476
}
477477

@@ -505,7 +505,12 @@
505505

506506
var parentElement = options.parentElement || "div";
507507
var template = options.template || options;
508-
return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings);
508+
509+
//If a parent is specified, return it; otherwise only return the generated children.
510+
if(options.parentElement)
511+
return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings);
512+
else
513+
return $("<" + parentElement + "/>").loadTemplate(template, value, internalSettings).children();
509514
});
510515
$.fn.loadTemplate = loadTemplate;
511516
$.addTemplateFormatter = addTemplateFormatter;

0 commit comments

Comments
 (0)