djax icon indicating copy to clipboard operation
djax copied to clipboard

DOM replacement callbacks

Open WTVader opened this issue 11 years ago • 3 comments

I'm not able to achieve page transitions with the mentioned DOM replacement callbacks, resp. the example in the documentation or from your demo site. The callback function (e.g. "transition") doesn't seem to have any impact and an immediate content replace still occurs. Any ideas what's wrong with that or what I'm missing?

WTVader avatar Jun 16 '13 10:06 WTVader

Are you copying/pasting right from the readme? If so there was a typo there which I've just corrected. Are you using the latest version of the plugin?

Does http://brianzeligson.com/djax/ use page transitions for you? If not what browser are you using? If so, try this (the initialization code I'm using on that site) inside your document ready callback, making sure to adjust the updatable class as needed.

                      var replace = function($newEl) {
                var $oldEl = $(this);
                $oldEl.slideUp('fast', function () {        
                    $newEl.hide();
                    $oldEl.after($newEl);
                    $newEl.slideDown('slow');
                    $oldEl.remove();
                });

            }

           $('body').djax('.updatable', [], replace);

beezee avatar Jun 16 '13 14:06 beezee

Ok, the problem was that my updateable container didn't has an id. Now it works for me, but I recognized that the stuff I passed into djaxLoad doesn't fire anymore (e.g. pageview tracking with Google Analytics). Is this another mistake on my side or is it cause by the djax code?

WTVader avatar Jun 16 '13 21:06 WTVader

I'd suspect it's something in your initialization code, since the example included in the repo uses both DOM replacement callbacks and a bind to djaxLoad, and both are fired properly.

Do you see the response logged to the console when navigating the demo code in the repo?

beezee avatar Jun 16 '13 21:06 beezee