Problems getting started

67 views
Skip to first unread message

Denny Dombkowski

unread,
Jul 23, 2013, 6:43:00 PM7/23/13
to sam...@googlegroups.com
This is my very simple code to try to get started:

 var app = Sammy('#main', function () {
     this.get('#/dorouteswork', function () {
         yestheydo();
     });
     this.get('#/', function () {
         alert('loaded!');
      });
 });
 app.run('#/');

function yestheydo() {
    alert('Yes they do!')
}

A lot was essentially copied from the website.

When I open the page, I get a "loaded!" alert, which means an initial route successfully loads.  However, when I follow my home page with /dorouteswork, or {page}/#dorouteswork, or {page}/#/dorouteswork), I get a 404 error.  What am I missing?

Mike Aguilar

unread,
Jul 23, 2013, 6:54:55 PM7/23/13
to sam...@googlegroups.com
Does www.yoursite.com/#/dorouteswork resolve to anyting?

Denny Dombkowski

unread,
Jul 24, 2013, 10:39:40 AM7/24/13
to sam...@googlegroups.com
It seems to resolve to the base route.  AKA, I get a "loaded!"  alert, but not a "Yes they do!" alert.

I should mention that this site is on IIS.  It's intended to eventually make AJAX requests to an API controller.  The site is dev.demo.com in my hosts file.  Is there any configuration I have to do in IIS to make the routing work?

Joshua Austill

unread,
May 11, 2016, 9:17:04 PM5/11/16
to Sammy.js
I'm having a very similar issue, also on IIS.  Here's my code

Enter code here... var app = Sammy('#page', function () {

        this.get(/\#\/(.*)/, function(context) {
            console.log("hash route called");
            $(".navbar-nav .dropdown").removeClass("open");
            ko.cleanNode(context.$element()[0]);
            var url = $$.getUrlFromHash(context.path, "/", "/");
            context.load(url)
                .swap()
                .then(function() {
                    console.log("callback after partial hit");
                    ko.punches.enableAll();
                    ko.applyBindings(appVM, context.$element()[0]);
                    app.run();
                });
        });
    });

    app.run();

My initial route loads, the first link I click loads, then links just don't do anything.  It's like Sammy crashes or something, because it still stops the default action, it just doesn't match any routes, after the first one...

I've been working on this for DAYS, and I'm so frustrated I could scream :(
Reply all
Reply to author
Forward
0 new messages