This is a migrated thread and some comments may be shown as answers.

Change event has allways backButtonPressed=true (args)

4 Answers 18 Views
SPA
This is a migrated thread and some comments may be shown as answers.
phx255
Top achievements
Rank 1
phx255 asked on 17 Nov 2016, 05:47 PM

Hi!, i0m triying to use the event change to capture when user push the Backbutton but the event Change (args e.backButtonPressed) is allways true:

I'm missing something?

The app navigate when user push on link like this <a href="/#previsiones">Previsiones</a>

 

01.SAOO.Routes = function () {
02.    var router = new kendo.Router({
03.        root: "/",
04. 
05.        routeMissing: function (e) {
06. 
07.        },
08.        back: function (e)
09.        {
10.             
11.             
12.            SAOO.theme.page.leftMenu.change(e.url);
13.        },
14.        change: function (e) {
15. 
16.            
17.            if (SAOO.application.loaded==false)
18.            {
19.                SAOO.theme.page.leftMenu.change(e.url);
20.            }
21.             
22.            
23. 
24. 
25. 
26.             
27.        },
28.        root: "/"
29.    });

Thx!!

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 21 Nov 2016, 10:07 AM
Hello Jaime,

I was able to observe the described behaviour on my side.

Our developers' team will investigate it additionally.

In the meantime, I can suggest the following workaround: 

As the back event of the Router is fired before the change event when the back button is clicked, I can suggest using a flag to check if the back button is clicked:

var flag = false;
back: function(){
 flag = true;
}
 
change: function(){
 if(flag){
  //custom code
 }
 flag = false;
}

I hope this will help to achieve the desired result.

Regards,
Stefan
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
0
phx255
Top achievements
Rank 1
answered on 21 Nov 2016, 10:46 AM

I'm trying that code but back event is not working (not fired)

I'm using Kendo UI v2016.3.1118

Thanks!

0
Accepted
Stefan
Telerik team
answered on 23 Nov 2016, 06:27 AM
Hello Jaime,

I did notice that if the event handler is used in the Router initialization, the event is indeed not fired.

Still, after testing, I can confirm that the event is correctly fired if the event is bind to the router after initialization. Please check how to bind the back event after the router is initialized:

router = new kendo.Router({
    init: function() {
        main.render("#root");
    }   
});
 
router.bind("back", function (e) {
    console.log("back", e);
});
 
As this is not an expected behaviour, I will forward this to our developers' team for further investigation.

Regards,
Stefan
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
0
phx255
Top achievements
Rank 1
answered on 23 Nov 2016, 08:28 AM

Thanks! now it's works perfect.

 

Tags
SPA
Asked by
phx255
Top achievements
Rank 1
Answers by
Stefan
Telerik team
phx255
Top achievements
Rank 1
Share this question
or