Search code examples
jquery-mobilemobiscroll

onSelect callback on Mobiscroll Datepicker


In one of my projects i am using Jquery mobile and Mobiscroll 2.0 (as datetime picker) I use a generic callback on all Scrollers to get a call when a value is set.

$('.input-datetime').scroller({preset: 'datetime',
     mode: 'scroller',
     onSelect: __datetimeOnSelectDelegate});

now in the function below, I would like to check and see which "input" element's value is being set?

function __datetimeOnSelectDelegate(textDate, inst) { 
         if ($(inst).attr("id") == "StartDate") {
           //Do something
         }
}

The above statement won't work!

Would you be able to show me how i can access the Id of the input element on which the Scroller is hooked on?


Solution

  • The "inst" is the mobiscroll object. The HTML object is "this". Use

    if (this.id == "StartDate") {
     //do something
    }