This is something I've done 100 times, but I can't spot why it's not binding. I'm creating a itemized list from a TAFFY database.
// get matching data from tfPLdata
var ts="";
var match=0;
tfPLdata({"vType":{likenocase:vType},"vSubType":{likenocase:vSubType}}).each(function (record,recordnumber) {
match++;
ts+="<div class='vWRAP' id='vh_"+recordnumber+"'>";
ts+="<div class='vTN'>"+record["vTypeName"]+"</div>";
ts+="<div class='vP'>"+record["vPrice"]+"</div>";
ts+="</div>";
});
the result looks like this
<div class='vWRAP' id='vh_0'>
<div class='vTN'>my corn seed 2</div>
<div class='vP'>165.00</div>
</div>
<div class='vWRAP' id='vh_1'>
<div class='vTN'>my corn seed 1</div>
<div class='vP'>150.00</div>
</div>
then I'm trying to bind CLICK to the class .vWRAP
$(".vWRAP").click(function(){
console.log("test");
});
but it just doesn't fire.
Why?
========================================
I added the code:
$(function() {
$(".vWRAP").each(function(){
console.log( $(this).attr("id") );
$(this).click(function(){
console.log("test");
});
});
});
and it correctly shows the ID for each .vWRAP. It still won't bind "click" however.