htmlknockout.jssammy.js

Sammy.js : Partial calling/rendering my html twice


I am new to knockout and sammy. I am implementing SPA using Sammy(router) and KnockOut(binding).

I have below code.

this.get('#/Page/:operation', function (context) {
            this.partial('templates/Page1.html', { cache: false }).then(function (content) {
                // the first argument to then is the content of the
                // prev operation
                $('#sammyDiv').html(content);
            });
        });

When I checked the console it's saying "You cannot apply bindings multiple times to the same element.(…)".

Am I doing anything wrong here?

What's the difference between Partial and Render?


Solution

  • Thanks for the response and comments. Issue was with Sammy router.

    this.get('#/Page/:operation', function (context) {
                this.partial('templates/Page1.html', { cache: false }).then(function (content) {
                    // the first argument to then is the content of the
                    // prev operation
                    $('#sammyDiv').html(content);
                });
            });
    

    changed to

    this.get('#/Page/:operation', function (context) {
                this.partial('templates/Page1.html', { cache: false });
            });
    

    It worked perfectly fine. Thanks again.