Skip to content

Conversation

@bard
Copy link

@bard 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 5 commits October 9, 2011 20:29
…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>
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
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant