javascript - SmoothState onAfter callback -
i have site has elements slider on pages. trying implement smoothstate js running issue of second page breaking. know through documentation need add onafter
callback wondering , how applied. apparently can tricky if unfamiliar ajax.
and code have fires script:
$(function(){ 'use strict'; var $page = $('#uber'), options = { debug: true, prefetch: true, cachelength: 2, onstart: { duration: 250, // duration of our animation render: function ($container) { // add css animation reversing class $container.addclass('is-exiting'); // restart animation smoothstate.restartcssanimations(); } }, onready: { duration: 0, render: function ($container, $newcontent) { // remove css animation reversing class $container.removeclass('is-exiting'); // inject new content $container.html($newcontent); } } }, smoothstate = $page.smoothstate(options).data('smoothstate'); });
does have ideas on how add onafter
callback?
i've started trying out smoothstate, here first worked me.
$(document).ready(function(){ prep(); }); $('#main').smoothstate({ onafter: function() { prep(); } }); function prep(){ $('#loadbtn').click(function () { $( '#remote1' ).load( 'external.html #myexternaldiv', function( response, status, xhr ) { if ( status == 'error' ) { var msg = 'sorry there error: '; $( '#error' ).html( msg + xhr.status + ' ' + xhr.statustext ); } $('#remote1').slidetoggle(); }); }); } // prep
so put stuff go $(document).ready section prep() function. call both doc init , onafter.
Comments
Post a Comment