I have the following template in Backbone, all gets rendered perfectly.
<a href="#list" data-role="button" id="button" class="all-unselected"></a>
<a href="#" data-role="button" id="button" class="suggested-unselected"></a>
<a href="#" data-role="button" id="button" class="friends-unselected"></a>
<a href="#" data-role="button" id="button" class="private-unselected"></a>
<a href="#" data-role="button" id="button" class="buzz-unselected"></a>
<script type="text/javascript">
var buttons = $("a#button");
for(var i=0; i<buttons.length; i++){
$(buttons[i]).bind('touchstart', select, false);
$(buttons[i]).bind('touchend', unselect, false);
}
function select(){
alert('test');
}
function unselect(){
alert('unselect');
}
</script>
The touchstart doesn't get triggered however if I write the following:
<a href="#" data-role="button" id="button1" class="suggested-unselected"></a>
<script type="text/javascript">
document.getElementById('button1').addEventListener('touchstart', select, false);
function select(){
alert('test');
}
function unselect(){
alert('unselect');
}
</script>
it works. As if jQuery can't bind the event. What might be the problem?