Monaca Onsen UI Discord Chat Github Repo

Prechange tab event is triggered too often



  • Hello,

    I have a production app developed with Cordova and Onsen UI.
    I have a tab bar component (Tous les sports/Individuels/Collectifs) :
    0_1545143453846_yrc1.jpg

    And i declared that few lines for prechange event :

    $('body').on('prechange', '#tabbar-filters', function(e) {
        prechangeTab(e.originalEvent);
    });
    

    Tab bar is working great. I have a function to put video on fullscreen, it works great on first tab but when I am in Individuels tab and I want to put my video on fullscreen, prechange event is triggered and I don’t know why because I don’t change tab.

    In my function associated with fullscreen icon, there is :

    screen.orientation.lock('landscape');
    

    From https://github.com/apache/cordova-plugin-screen-orientation

    When I remove this line, prechange event is not triggered but I don’t understand why this line triggers event. I don’t understand too why it works great on first tab and not after have changed tab.

    Do you have any idea ?

    Thank you per advance.



  • @zyostes said in Prechange tab event is triggered too often:

    $(‘body’).on(‘prechange’, ‘#tabbar-filters’, function(e) {
    prechangeTab(e.originalEvent);
    });

    Give this a shot:

    Instead of using $(‘body’).on(…) which bubbles events for the whole document body,

    Try

    $(#FormName).on(…), where FormName is the page you are targeting.

    HTH,
    Jamal



  • Thank you for your answer.

    The problem is still here. For information, prechange event is triggered two times when I enter in fullscreen and one time when I leave fullscreen.

    Another information is that apparently, the problem appears only in iOS.