Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

PURE plugin fix & warn on load error #113

Open
wants to merge 5 commits into
from
Commits on Oct 9, 2011
  1. Use PURE's render() instead of autoRender() if directives are given. …

    bard committed Oct 9, 2011
    …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>
        <html>
          <head>
            <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.use('Pure');
    
                    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() {
                    app.run('#/');
                });
            </script>
          </head>
          <body>
            <div id="main">
              <div class="summary">[<span class="state"></span>] <span class="summary-text"></span></div>
            </div>
          </body>
        </html>
  2. Don't assume happy path, give some notice if load() errors out (e.g. …

    bard committed Oct 9, 2011
    …because of JSON parse error).
Commits on Feb 8, 2012
  1. Allow setting an 'exit' callback for when a route is left.

    bard committed Feb 8, 2012
    Example:
    
    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
    });
  2. Missing bit from fb40b1f.

    bard committed Feb 8, 2012