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

_back is always defined in query parameter

3 Answers 53 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Seyfor
Top achievements
Rank 1
Seyfor asked on 05 Feb 2016, 12:41 PM

It says it should appear only when back button is pressed, but this is not the case in version 2016.1.125. 

There are some changes in kendo.router.js file in _checkUrl method which I think is not correct. backCalled is always undefined, which means backButtonPressed parameter in trigger method is always true.

if (this.trigger(CHANGE, {
url: current,
backButtonPressed: !backCalled

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 09 Feb 2016, 09:17 AM
Hello,

We will need a test case for this. The last change of the router is this one - I fiddled with the tests a bit, but it seems like the _back query parameter, but it seems to work as expected:

asyncTest("navigate method navigates to a given url", 2, function(){
    var router = new kendo.Router();
 
    var i = 0;
    router.bind('change', function(e) {
      console.log(e);
    });
 
    router.route("/foo", function(params) {
        if (++i == 2) {
            start();
            ok(params._back);
        } else {
          ok(!params._back); 
        }
 
    });
 
    router.start();
    router.navigate("/foo");
    router.navigate("/bar");
    history.back();
});




Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Seyfor
Top achievements
Rank 1
answered on 09 Feb 2016, 10:58 AM

It is always true for me in version: Kendo UI v2016.1.125

The first time backCalled is undefined so, backButtonPressed is true (maybe you would need to remove ! in this.trigger call)

_checkUrl: function () {
   var adapter = this.adapter, current = adapter.current(), newLength = adapter.length(), navigatingInExisting = this.historyLength === newLength, back = current === this.locations[this.locations.length - 2] && navigatingInExisting, backCalled = this.backCalled, prev = this.current;
   if (current === null || this.current === current || this.current === decodeURIComponent(current)) {
        return true;
   }
   this.historyLength = newLength;
   this.backCalled = false;
   this.current = current;
   if (back && this.trigger('back', {
        url: prev,
        to: current
   })) {
     adapter.forward();
     this.current = prev;
     return;
   }
   if (this.trigger(CHANGE, {
       url: current,
       backButtonPressed: !backCalled  //on first time is undefined, then always false and ! transformed it into true,
   })) {
       if (back) {
          adapter.forward();
       } else {
          adapter.back();
       this.historyLength--;
   }
   this.current = prev;
   return;

0
Petyo
Telerik team
answered on 11 Feb 2016, 08:45 AM
Hello,

I am aware of the implementation, but it seems to pass the tests we have. Can you present a runnable sample that demoes the problem? Thank you in advance. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
SPA
Asked by
Seyfor
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Seyfor
Top achievements
Rank 1
Share this question
or