Search code examples
javascriptjquery-mobilecordovacordova-3

jquery mobile slider event not detected in cordova


I am trying to get on/off events for a slider widget in my mobile application. Here is the jsfiddle

var val = 'on';
$('select#flag').change(function() {
    if(val!==$(this).val()){
        alert($(this).val());
    }
    val = $(this).val();
});

which works fine but not on my mobile using cordova/phonegap 3.5 and JqueryMobile.

  • Am I doing anything wrong?

Solution

  • When you bind an event like this it will act as an event delegation. Basically object don't need to exist in a DOM when you execute this binding.

    I found my answer here and copied its explanation, it solves my problem getting the event.