Skip to content

PURE plugin fix & warn on load error #113

wants to merge 5 commits into from

1 participant

bard commented Oct 11, 2011

Deals with a couple of issues that bit me on my first day with SammyJS.

The second is more of a beginning of a fix (I haven't looked into Sammy's own logging facilities yet).

bard added some commits Oct 9, 2011
@bard bard Use PURE's render() instead of autoRender() if directives are given. …
…autoRender() with directives leads to unexpected results.

Before the fix, this test case results in the error "The node
.summary-text" was not found in the template" being printed to the
console and the template not being processed as expected.

    <!DOCTYPE html>
        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/pure.js"></script>
        <script type="text/javascript" src="js/sammy/sammy.js"></script>
        <script type="text/javascript" src="js/sammy/plugins/sammy.pure.js"></script>
        <script type="text/javascript">
            var app = $.sammy('#main', function() {

                this.get('#/', function(context) {
                    var data = {
                        summary: 'buy bread',
                        state: 'done'
                    var directives = {
                        '.summary-text': 'summary',
                        '.state': 'state'

                    context.pure('#main', data, directives);

            $(document).ready(function() {
        <div id="main">
          <div class="summary">[<span class="state"></span>] <span class="summary-text"></span></div>
@bard bard Don't assume happy path, give some notice if load() errors out (e.g. …
…because of JSON parse error).
@bard bard Merge remote-tracking branch 'remotes/upstream/master' a1faf5a
@bard bard Allow setting an 'exit' callback for when a route is left.

this.get('#/foo/bar', function(context) {
    // business as usual
}, function() {
    // run when user navigates away from #/foo/bar
    // useful e.g. to undo anything specific to the #/foo/bar view
@bard bard Missing bit from fb40b1f7. 1632f91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.