_back is always defined in query parameter

4 posts, 0 answers
  1. Matjaž
    Matjaž avatar
    80 posts
    Member since:
    Jul 2015

    Posted 05 Feb Link to this post

    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

  2. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 09 Feb Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Matjaž
    Matjaž avatar
    80 posts
    Member since:
    Jul 2015

    Posted 09 Feb in reply to Petyo Link to this post

    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;

  5. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 11 Feb Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready