javascriptjqueryhtmlsammy.js

Cancel Sammy "before" if AJAX call returns false


I have following issue.

I am building a website with Sammy routing.

Now I want that before every Sammy Call an Ajax function is called and based on it's result it will cancel Sammy or Not.

       this.before( function () {
        return app.dataModel.CheckAndSaveChanges();
    });

Any Suggestion How I could make this before work to wait for my Ajax to be ready so I can evaluate the result and then return true or false.

Or should I go a different Approach?


Solution

  • Found it the right solution.

    http://sammyjs.org/docs/api/0.7.4/Sammy.Application.methods.around