|
When you want to fill a part of your html once and show it. You can use $(selector).bind(data,{fill:true}); which require jBind plugin. jBind will bind will first find the html content of matched selector and fill it's content with assigned data. You can find out more by downloading it's sample package or reading it's documentation. This feature is added in version 1.5.3
jQuery Fill Feature of jBind This way you can fill a part like this with data: <!--data--> <div class="viewBlock" id='{id}'> <b>{name} {family} </b>, <i>[ Birthdate: {birthdate} ] </i> </div> <!--data--> </div> </div> </body>
%3Cbody%3E%0A%20%20%20%20%3Cdiv%20id%3D%27template%27%3E%0A%20%20%20%20%20%20%20%20%3Cdiv%20class%3D%22content%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C%21--data--%3E%0A%20%20%20%20%20%20%20%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%20%20%20%20%20%20%20%3Cb%3E%7Bname%7D%20%7Bfamily%7D%3C%2Fb%3E%2C%20%3Ci%3E%5B%20Birthdate%3A%20%7Bbirthdate%7D%20%5D%3C%2Fi%3E%0A%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%3C%21--data--%3E%0A%20%20%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3Cdiv%20id%3D%27show%27%3E%3C%2Fdiv%3E%0A%3C%2Fbody%3E Using: $('#template').bindTo(data,{'root':'info',fill:true});
%24%28%27%23template%27%29.bindTo%28data%2C%7B%27root%27%3A%27info%27%2Cfill%3Atrue%7D%29%3B So the result is: {geshibot lang="html4strict"}<body> <div id="template"> <div class="content"> <div id="1" class="viewBlock"> <b>Scott Adams</b>, <i>[ Birthdate: June 8 1957 ]</i> </div> </div> </div> <div id="show"/> </body>{/geshibot You can download this file from jBind example package in download section. Tags: jBind | jQuery | Plugin |