miguel-perez / smoothState.js

Unobtrusive page transitions with jQuery.
MIT License
4.43k stars 508 forks source link

How About Loading the Whole Document #372

Open nazimwibsoft opened 5 years ago

nazimwibsoft commented 5 years ago

There should be a way in the Soothstate js to load the whole document if one need to? so we dont have to specify container Id it will just reload the whole content. I did some experiment and had to modify the script a bit.

I used this small piece of code to replace HTML content of whole document: document.open("text/html", "replace"); document.write(data); document.close();

This will execute all my scripts correctly and load the page like we normally do but with a transition giving user a transition experience without reload the page.

onReady will be Like this onReady: { duration: 0, render: function ($container, $newContent) {

                $container.removeClass('is-exiting');

                var currentUrl = $container.data('smoothState').href;
                var cache = $container.data('smoothState').cache;

                var currentPageCache = cache[currentUrl];

                document.open("text/html", "replace");
                document.write(currentPageCache.doc);
                document.close();
            }
        }

thunderpigeon commented 2 years ago

I couldn't get it to work. But, would be sweet if it did.