jquerytransitionsammy.js

knockout views transition in sammyjs


I want to use jquery fade in-between views. I'm unsure how to do this in sammy.js. I thought of writing a function...

function showFade(_selector, newView, VM) {
    $(_selector).load(newView, function() {            
        $(newView).fadeIn('slow');
        ko.applyBindings(VM, $(_selector)[0]);
    });

then calling it:

app.get('#/newfile', function(){
  mainView.currView('landing');
  var _view = new newfileVM(mainView);
  showFade('#pagecontent', '/app/files/newfile.html', _view);
});

But this doesn't work (I didn't think it would, but just tried anyway). I appreciate anyone help me with this. Thanks.


Solution

  • This is what worked for me. No one posted an answer so I'm answering this myself.

    function showFade(_selector, newView, VM) {
        $(_selector).load(newView, function() {            
            $(newView).hide().fadeIn('slow');
            ko.applyBindings(VM, $(_selector)[0]);
        });