Ignore route using Sammy.js on wordpress site

77 views
Skip to first unread message

Rōnin Dusette

unread,
Apr 23, 2018, 1:04:30 PM4/23/18
to Sammy.js

So, I have been searching for the last few hours and I can't figure this out. I have an SPA served via wordpress (it's something my work is forcing me to do, unfortunately), and I am using Sammy.js for the routing. It's routes absolutely fine, but they want to use some WP plugins on the contact page, so I need sammy to ignore a certain URI and just let wordpress serve up a page by itself. Again, sammy is doing everything it should, but I want it to ignore "/contact/" and just let wordpress serve it. Sammy keeps pulling in the home page and adding a trailing "/#/" to the end.

Here is what a part of my app.js file that has the sammy routes contains:


var app = $.sammy('#app', function() {
    this.use('Template');

    this.get('#/', function(context) {
        var str=location.href.toLowerCase();
        context.app.swap('');
        context.render('/wp-content/themes/financial-decisions/application/src/templates/home.html', {})
            .appendTo(context.$element());
    });

    this.get('/contact/', function(context) {
        // I want this route to be ignored and served by wordpress only
    });

    this.before('.*', function() {

        var hash = document.location.hash;
        $("nav").find("a").removeClass("current");
        $("nav").find("a[href='"+hash+"']").addClass("current");
    });

});

$(function() {
    app.run('#/');
});

})(jQuery);


Really, once sammy is ignoring that route and it makes the http request like normal, it would work, but I just can't get it to do so. Any suggestions?


Thanks.

Reply all
Reply to author
Forward
0 new messages