Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Prevent an event listener in firing many times for ionicModal?

$
0
0

@junerockwell wrote:

I have a modal with a type[search] in it. I needed to know if keyboard is open or hidden. So I'm using keyboard event listeners: window.addEventListener('native.keyboardshow', keyboardShowHandler, false); and window.addEventListener('native.keyboardhide', keyboardHideHandler, false);.

The first time the modal appears, the event handlers are only fire once every time a keyboard is visible and vice versa. Starting from the second to the third time, etc. that the modal is opened, the event handlers get fired more than once. For example, if modal has been opened the second time, the events fire twice. If modal is opened for the third time, events fire 3 times, and so on.

This only happens for modals. The events don't fire multiple times if it's just a regular page. An example of what I mean about "regular page" is a view that opens in response to an item clicked/tapped on a side menu.

I know that keyboard fires multiple times because I print something inside each keyboard handler function.

function keyboardshow(e) {
   console.log("keyboardshow()");

   var content = angular.element(document.querySelector('.has-filter-box'));
   content.css("bottom", _keyboardHeight + "px");
   console.log("content bottom: " + content.css("bottom"));
}
function keyboardhide(e) {
    console.log("keyboardhide()");
    var content = angular.element(document.querySelector('.has-filter-box'));
    content.css("bottom", 0);
    console.log("content bottom: " + content.css("bottom"));
}

The problem that's happening is, starting from the second time the modal is open, the changes to the bottom property of the modal's <ion-content> doesn't change even though the console.log says that the changes have been applied. So I'm thinking that it's the multiple fire events.

Any body know a solution for this?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>