nehakadam / AnyPicker

jQuery Picker Library for Android, iOS & Windows Phone. eg Date Picker, Time Picker, DateTime Picker, Custom Select etc
https://nehakadam.github.io/AnyPicker/
MIT License
116 stars 37 forks source link

AnyPicker dynamic register functionality #4

Closed projectsphonegapdev1 closed 8 years ago

projectsphonegapdev1 commented 8 years ago

We have a dynamic div for which we want to register date time picker at runtime and we also want to open that date time picker on a button click. So, please suggest as how can we achieve this?

when a particular view renders we are using this code: $('#MBCControlItem' + Id).AnyPicker( { mode: "datetime", dateTimeFormat: "hh:mm aa" }); At present, on click of it, it generates multiple dynamic "anypicker" divs,

nehakadam commented 8 years ago

This is happening because with a dynamic container, AnyPicker may be getting initialized more than once on the same element.

As a quick fix you can use $('#MBCControlItem' + Id).AnyPicker("destroy");, while hiding the container in which you are initializing AnyPicker.