|
jBind 1.5.0 has been updated to 1.5.1. This new version support Partial template, now you can bind parts of your aggregate data to a template.
jBind 1.5.1 and Partial TemplateThis new release support partial template: In all jBind previous version when we wanted to map just part of aggregate data to template we was forced to define the blank template for inner objects which we wanted to by pass. For example below we wanted to pass Publication: var data = [ { id:41, name:'Scott', family:'Adams', education:'Economics', history:"Scott Adams was born in Windham, New York in 1957 and received ...", birthdate: {month:'June',date:8,year:1957}, Publications: [{book:'The Dilbert Future',year:1997},{book:'The Dilbert Principle',year:1996}] }, { id:59, name:'Jack', family:'Welch', education:'Chemical Engineering', history:'Jack Welch was born in Peabody, Massachusetts to John, ...', birthdate: {month:'November',date:19,year:1935}, Publications: [{book:'Winning',year:2005}] } ]; var node = $(template).bindTo(data); $(node).appendTo('#show');
var%20data%20%3D%20%20%20%20%20%5B%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%3A41%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%27Scott%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20family%3A%27Adams%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20education%3A%27Economics%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20history%3A%22Scott%20Adams%20was%20born%20in%20Windham%2C%20New%20York%20in%201957%20and%20received%20...%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20birthdate%3A%20%7Bmonth%3A%27June%27%2Cdate%3A8%2Cyear%3A1957%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Publications%3A%20%5B%7Bbook%3A%27The%20Dilbert%20Future%27%2Cyear%3A1997%7D%2C%7Bbook%3A%27The%20Dilbert%20Principle%27%2Cyear%3A1996%7D%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20id%3A59%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%27Jack%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20family%3A%27Welch%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20education%3A%27Chemical%20Engineering%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20history%3A%27Jack%20Welch%20was%20born%20in%20Peabody%2C%20Massachusetts%20to%20John%2C%20...%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20birthdate%3A%20%7Bmonth%3A%27November%27%2Cdate%3A19%2Cyear%3A1935%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Publications%3A%20%5B%7Bbook%3A%27Winning%27%2Cyear%3A2005%7D%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%3B%0Avar%20node%20%3D%20%24%28template%29.bindTo%28data%29%3B%0A%24%28node%29.appendTo%28%27%23show%27%29%3B In jBind 1.5.0 we had to define something like this: <!--data--> <div class="viewBlock" id='{id}'> {history} <!--birthdate--> {month} {date} {year} </div> <!--birthdate--> <!--Publications--> <!--Publications--> </div> <!--data--> </div> -
%3Cdiv%20class%3D%22content%22%3E%0A%20%20%20%20%20%3C%21--data--%3E%0A%20%20%20%20%20%20%20%20%20%3Cdiv%20class%3D%22viewBlock%22%20id%3D%27%7Bid%7D%27%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%23%7Bid%7D%3Cbr%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cb%3E%7Bname%7D%20%7Bfamily%7D%3C%2Fb%3E%2C%3Cbr%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3Ci%3E%7Beducation%7D%3C%2Fi%3E%2C%3Cbr%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bhistory%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21--birthdate--%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cdiv%20class%3D%27age%27%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bmonth%7D%20%7Bdate%7D%20%7Byear%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21--birthdate--%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21--Publications--%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21--Publications--%3E%0A%20%20%20%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%20%3C%21--data--%3E%0A%20%3C%2Fdiv%3E%0A%20 In jBind 1.5.1 I simplified the templating. You can ignore the inner template and jBind will bypass it automatically: <!--data--> <div class="viewBlock" id='{id}'> {history} <!--birthdate--> {month} {date} {year} </div> <!--birthdate--> </div> <!--data--> </div> -
%3Cdiv%20class%3D%22content%22%3E%0A%20%20%20%20%20%3C%21--data--%3E%0A%20%20%20%20%20%20%20%20%20%3Cdiv%20class%3D%22viewBlock%22%20id%3D%27%7Bid%7D%27%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%23%7Bid%7D%3Cbr%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cb%3E%7Bname%7D%20%7Bfamily%7D%3C%2Fb%3E%2C%3Cbr%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3Ci%3E%7Beducation%7D%3C%2Fi%3E%2C%3Cbr%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bhistory%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21--birthdate--%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cdiv%20class%3D%27age%27%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7Bmonth%7D%20%7Bdate%7D%20%7Byear%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%21--birthdate--%3E%0A%20%20%20%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%20%3C%21--data--%3E%0A%20%3C%2Fdiv%3E%0A%20 Check downloads for jBind sample or click here. You can read more about jBind here. Special thanks to Reza Owliaei who has reported this issue. Tags: jBind | jQuery | Plugin |