Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Basic routing with two properties

$
0
0
I make this routing test with properties, search and registration for vehicles

my code 

$(function() {

  Router = can.Control({

      "vehicles" : function(){
        console.log("the hash is #!vehicles")
      },
      "vehicles/:registration" : function(data){
        console.log("the hash is #!vehicles/:registration "+data)
      },
      "vehicles/:search" : function(data){
        console.log("the hash is #!vehicles/:search "+data)
      }

    });


    can.route("vehicles");
    can.route("vehicles/:registration");
    can.route("vehicles/:search");
    
    can.route.ready();

    new Router(document);

});

and the tests

Test one 

>> can.route.attr("search", "121-TYU-898")

a {_dataObject_cid".map1"_computedBindingsObject__bindEventsObject_bindings2}
    1. __bindEventsObject
    2. _bindings2
    3. _cid".map1"
    4. _computedBindingsObject
    5. _dataObject
    6. route"vehicles/:search"
    7. search"121-TYU-898"
    8. __proto__t.Construct


That ok, but no message ("the hash is #!vehicles/:search "+data) in console

Test two

>> can.route.attr("registration", "333-TYU-898")

a {_dataObject_cid".map1"_computedBindingsObject__bindEventsObject_bindings2}
    1. __bindEventsObject
    2. _bindings2
    3. _cid".map1"
    4. _computedBindingsObject
    5. _dataObject
    6. registration"121-TYU-898"
    7. route"vehicles/:registration"
    8. __proto__t.Construct

That ok, but no message ("the hash is #!vehicles/:registration "+data) in console

Test three 

>> can.route.attr("search", "444-TYU-555")

a {_dataObject_cid".map1"_computedBindingsObject__bindEventsObject_bindings2}
    1. __bindEventsObject
    2. _bindings2
    3. _cid".map1"
    4. _computedBindingsObject
    5. _dataObject
    6. registration"121-TYU-898"
    7. route"vehicles/:registration"
    8. search"333-TYU-808"
    9. __proto__t.Construct

I don't understand, for me, i expect this answer 

a {_dataObject_cid".map1"_computedBindingsObject__bindEventsObject_bindings2}
    1. __bindEventsObject
    2. _bindings2
    3. _cid".map1"
    4. _computedBindingsObject
    5. _dataObject
    6. route"vehicles/:search"
    7. search"444-TYU-555"
    8. __proto__t.Construct


Could you help to understand, thank you

Viewing all articles
Browse latest Browse all 3491

Trending Articles