1)
I am not sure what you referring to by "string templates".
but I'd like the following version better :
var buildButton = $('<button id="bulid-2.3.0">Build</button>');
$("#sandbox").append(buildButton);
buildButton.bind("click",function (){
console.log(version);
});
is there any reason to use the version you have mentioned over this?
2)
when using loop just wrap the loop body in a function to avoid dynamic
variables being overridden.
eg:
for (var i=0; i < 5; i++) {
(function (buttonId) {
var buildButton = $('<button>x</button>');
buildButton.bind("click", function () {
console.log(buttonId);
});
})(i);
}
or just write loop body as a separate function , which some times can be
more readable
function addButton(buttonId) {
var buildButton = $('<button>x</button>');
buildButton.bind("click", function () {
console.log(buttonId);
});
};
for (var i = 0; i < 5; i++) {
addButton(i);
}
3)
+1 for using 'incremental for loop' for arrays
--
With regards,
*Manu*ranga Perera.
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture