Change DOM before bringPageTop()



  • Hey,

    I use the bringPageTop method to load the view-1.html and show it. When I change the DOM in the then part it will be executed after the animation and the html is already shown. So you see how it changes.

    I want to change the dom and then do the animation etc. Is there a way to preload the html file?

    Thank you

    myNavigator.bringPageTop('html/view-1.html',
      {animation: 'slide',
        animationOptions: {
        duration: 0.2
        ,delay: 0
        }
      })
       .then(function() {
    
          $('.div-in-view-1.html').text("2323");
    
        });
    

  • Onsen UI

    @Flosef2 If it’s the first time you push view-1.html with bringPageTop then it just performs a normal pushPage. That means your page is only a template (a string) and doesn’t exist as DOM per se. We are discussing about adding templating functionality to support this in gh#1447

    However, you have a way to modify the created pages in their init event. That event will run before animations. More info here.

    frandiox created this issue in OnsenUI/OnsenUI

    open Specs: Utility pack. #1447



  • @Fran-Diox thanks a lot!

    For others having this problem you can use something like this:

    document.addEventListener("init", function(e) {
      if (e.target.matches("#ID-OF-YOUR-PAGE-IN-HTML-FILE")) {
        
        //DO SOMETHING BEFORE ANIMATION
    
      }
    
    


  • btw.
    why can I not mark the topic as solved?

    0_1466608622650_Bildschirmfoto 2016-06-22 um 17.16.36.png



  • @Flosef2 You need to first click “Ask as Question?” then when you view the thread, you will see a button “Solved” or mark as solved.


Log in to reply