- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
AJAX 和 Masonry grid 有问题.砌体网格很简单,没有在正确的时间启动。
在滚动或使用参数搜索转到特定类别之前,效果非常好。
可以找到示例站点here .
Masonry 是一个 JavaScript 网格布局库。通常与 Bootstrap 或其他未正确对齐项目的网格系统一起使用。示例:
下一列将添加到旧列之上。提供与 unloaded images 几乎相同的输出这使得图像重叠。这通常可以通过使用我已经包含在提供的代码中的 imagesLoaded
来解决。
Masonry 在 AJAX 之后没有被解雇。这意味着它根本不起作用。所以柱子在没有砌体的情况下被加载。
请参阅sample site .
滚动搜索和参数搜索均由 Toolset 提供.他们有一个很好的系统,可以很容易地在特定时间加载 JS:
所以在分页之后和之前/期间/之后Parametric search .由于问题是在滚动之后,并且在参数搜索的结果更新之后,我想在这一刻启动 Masonry 网格。
最简单的示例是滚动完成时,也称为分页。
我使用了 reloadItems
,因为我猜是正确的。如果我错了,请纠正我。 Resource .
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
$container.masonry('reloadItems')
});
根据我的理论,它会在滚动时重新加载所有项目,因此它们会被正确排列。但它没有任何改变。
我也试过以下方法:
jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
var $container = $('.masonry-container');
$container.imagesLoaded(function() {
$container.masonry('reload');
$container.masonry({
isInitLayout : true,
itemSelector: '.col-md-3'
});
});
//and on ajax call append or prepend
$container.prepend($data).imagesLoaded(function(){
$container.masonry( 'prepended', $data, true );
});
});
我还尝试在参数搜索结果更新后重新加载项目。
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
$container.masonry('reloadItems')
});
但这也不起作用。
Masonry 也使用其中一种方法添加到页脚中。
(function( $ ) {
"use strict";
var $container = $('.masonry-container');
$container.imagesLoaded( function () {
$container.masonry({
columnWidth: '.col-md-3',
percentPosition: true,
itemSelector: '.col-md-3'
});
});
})(jQuery);
你有什么想法吗?我哪里做错了?
加载页面时
Uncaught ReferenceError: data is not defined
滚动时
Uncaught ReferenceError: $container is not defined
(function( $ ) {
// Initiate Masonry
"use strict";
var $container = $('.masonry-container');
$container.imagesLoaded( function () {
$container.masonry({
columnWidth: '.item',
percentPosition: true,
itemSelector: '.item',
isAnimated: true // the animated makes the process smooth
});
});
$(window).resize(function() {
$('.masonry-container').masonry({
itemSelector: '.item',
isAnimated: true
}, 'reload');
});
})(jQuery);
//and on ajax call append or prepend more items
var $data = $(data).filter(".item");
$container.prepend($data).imagesLoaded(function(){
$container.masonry( 'prepended', $data, true );
});
我也更新了 imagesloaded 到最新版本。
可以找到脚本here .
.item
我添加了类 .item
而不是使用 col-md-3,因为我认为这是一个更好的解决方案。
意味着 HTML 现在是这样的:
<div class="container">
<div class="masonry-container">
<div class="item">
<!-- Content comes here -->
</div>
<div class="item">
<!-- Content comes here -->
</div>
<div class="item">
<!-- Content comes here -->
</div>
<div class="item">
<!-- Content comes here -->
</div>
...
</div>
</div>
等等。
仍然是控制台错误。
有什么解决办法吗?
最佳答案
通过删除一些重复等问题解决了这个问题。
然后使用以下内容:
(function( $ ) {
"use strict";
var $container = $('.masonry-container');
$container.imagesLoaded( function () {
$container.masonry({
columnWidth: '.item',
percentPosition: true,
itemSelector: '.item'
});
});
$( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
$container.masonry('reloadItems').masonry();
});
$( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
$container.masonry('reloadItems').masonry();
});
$( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {
$container.masonry('reloadItems').masonry();
$container.imagesLoaded( function() {
$container.masonry();
});
});
$( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
$container.masonry('reloadItems').masonry();
$container.imagesLoaded( function() {
$container.masonry();
});
});
})(jQuery);
这是在 footer.php 中添加的。
关于javascript - Initiate Masonry - 在无限滚动和参数搜索之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38712783/
我的代码有问题。它总是忽略if(userDigit=1).. 谁能告诉我这里出了什么问题? for(i=0; i=1) { //
我正在尝试从字符串 html_doc 中提取 id=obj1 并尝试将 onclick 函数 附加到它 document.addEventListener("DOMContentLoaded", fu
我正在尝试使用 css 动画来动画化从一个类到另一个类的变化。基本思想是在用户单击按钮时为从一个边缘滑动到另一个边缘的 slider 设置动画。 到目前为止我的代码。 https://jsfiddle
我目前面临使用前后伪元素淡入导航项的问题。 当我悬停导航项时,它必须将其背景颜色从白色更改为蓝色。没什么疯狂的。但它也必须显示两个背景图像,分别通过将::before 伪元素从 0 更改为 1 和::
有没有简单的方法可以在最近的sqlite版本中修改表,使其与预定义的架构匹配? 架构: war_id INTEGER NOT NULL, clanname VARCHAR(64), clanhomep
我该如何将我的搜索结果变成这样的: http://i.stack.imgur.com/NfPGs.png 结果显示特定术语在单元格中的位置。 我目前有这个基本的搜索脚本: $terms =
我正在尝试使用按钮创建输入字段。但我想要的是,当创建输入字段时,我想用相同的按钮隐藏创建的输入字段。我尝试了 slideToggle 函数,但效果不是很好。 $('#addEmail').one('
我想做这样的事情: Reference of image. 我所做的:两个 UIImagesView,一个带有 UIViewContentModeLeft,另一个带有 UIViewContentMod
我在使用应该修复表中列的插入触发器时遇到了问题: id - auto increment int thread_id - int [NULL] 我想要实现的是将 thread_id 设置
我使用 tinter.after() 每 200 毫秒 刷新一次树莓派上模拟时钟的显示。一开始还可以,但逐渐地,每次刷新之间的时间达到大约 2-3 秒。是否有任何解决方案可以将刷新间隔保持在 200m
我有一个按钮,它使用::after 伪来填充背景。目前它从左到右填充,这在宽度从 0 到 100% 时有意义。但是,我希望它翻转它填充的方式。 a.project--link { margin:
我正在尝试添加带有伪元素:after的下划线来注释一些文本。 我的问题是,我想强调下划线。在此示例中,这是短语“实际上确实可以...”和“ ...不起作用”。 .test { margin-top
鉴于此: This is a test It is 有没有我可以应用到 的 CSS?那它会出现在“This is...”之前,并且在 PREVIOUS LINE 之前吗? float:left; d
我正在使用链接左侧的图像。 现在,我使用图像的::before 属性来显示,但它显示在链接的上方。 我需要对齐它。这是一张照片: Link 我使用的代码是: .vocabulary-duration
我有一个页脚有 与 6 body {background:#bbb;} .main-footer a::after { content: " | "; color: white; mar
我有一个父元素和一些子元素,但我不能直接更改它们的 CSS。所以,我试图在父元素的 CSS 中更改我 child 的 CSS。示例: .parent { & .child {
我可以 div:after { content: "hello" } 但我能否为 hello 文本添加标题,以便当我用鼠标悬停它时显示标题? 谢谢 最佳答案 你不需要伪元素: p { ba
CSS 2.1 :after 和 CSS 3 ::after 伪选择器(除了 ::after 旧浏览器不支持)?是否有任何实际理由使用更新的规范? 最佳答案 这是伪类与伪元素的区别。 除了 ::fir
「掏出钥匙开门,然后在黑暗中摸索着墙壁开关的位置,最后将室内的灯点亮。」 这是一个星期之前,我每天晚上下班回家时的固定戏码,也可能是大部分人每天回家时的经历。这种「一对一」的日常琐碎还有许多许
我正在尝试包装 , ,和具有 的元素修复我无法直接编辑的表单上的某些定位。由于某种原因,当我尝试使用以下代码时: $("label").before(""); $("input[type=tex
我是一名优秀的程序员,十分优秀!