- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的网站在大多数页面上都有类似 slider 的元素。我正在尝试实现 SmoothState JS,但遇到了第二页中断的问题。通过文档我知道我可能需要添加 onAfter
回调,但我想知道在哪里以及如何应用它。显然,如果不熟悉 Ajax,这可能会很棘手。
Here is the documentation on the issue.
这是我用来触发脚本的代码:
$(function(){
'use strict';
var $page = $('#uber'),
options = {
debug: true,
prefetch: true,
cacheLength: 2,
onStart: {
duration: 250, // Duration of our animation
render: function ($container) {
// Add your CSS animation reversing class
$container.addClass('is-exiting');
// Restart your animation
smoothState.restartCSSAnimations();
}
},
onReady: {
duration: 0,
render: function ($container, $newContent) {
// Remove your CSS animation reversing class
$container.removeClass('is-exiting');
// Inject the new content
$container.html($newContent);
}
}
},
smoothState = $page.smoothState(options).data('smoothState');
});
有人对我如何添加 onAfter
回调有任何想法吗?
最佳答案
我刚刚开始尝试 smoothState,但这是最先对我起作用的。
$(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 but there was an error: ';
$( '#error' ).html( msg + xhr.status + ' ' + xhr.statusText );
}
$('#remote1').slideToggle();
});
});
} // prep
因此,我将通常会进入 $(document).ready 部分的内容放入 prep() 函数中。然后我为 doc init 和 onAfter 调用它。
关于javascript - SmoothState onAfter 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33282004/
我在 jquery 循环插件上检索图像对象的宽度属性时遇到问题 $(function() { $('#image').cycle({ fx: 'fade',
我的网站在大多数页面上都有类似 slider 的元素。我正在尝试实现 SmoothState JS,但遇到了第二页中断的问题。通过文档我知道我可能需要添加 onAfter 回调,但我想知道在哪里以及如
我昨天很快就得到了关于 best autocomplete option for what I needed. 的惊人答案。 我想我可以使用 onAfter function call from Qu
我正在使用Kwicks jQuery plugin对于我的投资组合。我想在 kwicks 单击事件之后在列表项中显示一个子容器。我似乎无法找到一个钩子(Hook),至少在 kwicks 插件的参数内。
我正在使用 PHP 中的 cURL 实现,并利用 curl_multi_init() 和 curl_multi_exec() 并行执行批量请求。我已经这样做了一段时间,并且了解其中的一部分。 但是,请
我是一名优秀的程序员,十分优秀!