javascript - How to close Ionic2 Datetime popup without clicking Cancel button -
in ionic 2 project, need make user logout after idle timeout. while doing so, noticed cannot close datetime popup before invoking logout event , redirecting login page. need close popup before redirecting login page. below code sample working on
<ion-datetime (ioncancel)="oncanceldatetime()" [(ngmodel)]="datetime"> </ion-datetime>
the (ioncancel) event fired when close popup.
is there way invoke firing of event programmatically?
or there way close datetime popup?
currently there no official documented ionic 3 way close datetime picker programmatically.
however can use javascript 'dispatchevent' method trigger click on 'cancel' button of datetime picker.
here how it:
// reference clear button of datetime picker. var pickerclearbutton = document.getelementsbyclassname("picker-button")[0]; // create click event triggered var clickevent = new mouseevent("click", { "view": window, "bubbles": true, "cancelable": false }); // trigger event pickerclearbutton.dispatchevent(clickevent);
i believe job!!
Comments
Post a Comment