0

I am building a HTML5 application with Intel XDK and Jquery Mobile. I've created a listview and want to listen to its 'tap' event. My code is very similar to the tutorial's, but something is still wrong. Maybe it's the place where I put it? I'm puting the event listener right after I refresh the listview. Documentation hasn't helped much and I couldn't find any question similar to mine :/ Code:

list.listview("refresh");
$('#favourslist > li').bind('tap', function(e)
{
    console.log('tapped');
    //var targetValue=this.getAttribute('title');
    //alert(targetValue);                                        
});
rvcam
  • 157
  • 5
  • 15
  • list.listview("refresh"); Are you sure this is the syntax to refresh?? – Prasanna Aarthi Mar 24 '14 at 04:04
  • 1
    `$(document).bind('tap', '#favourslist > li', function(e)` since `li` are dynamically injected into DOM/ – Omar Mar 24 '14 at 08:41
  • @Omar thank you. Please submit your comment as an answer so it gets more visible to whoever visits this page. Also, if (just if) you could provide a link or a more complete explanation, it would be great. :) – rvcam Mar 24 '14 at 15:59
  • I'm glad it works for you :) honestly, this question has been answer many times. http://stackoverflow.com/a/22280822/1771795 It's called _event delegation_. – Omar Mar 24 '14 at 16:07

0 Answers0