在 jQuery .load() 之后激活砌体
如何在页面加载后激活 JS 和其他 jquery 功能,例如砌体。
我使用:
jQuery("#filterbox").load("mypage.html"}); works fine, but eg. mansory is not activated.
jQuery('#content #boxes').masonry({ columnWidth: 122, animate: true });
但第二个没有“激活”。
css和js在.load期间未激活是否正确,如果,之后如何激活它。
感谢您的帮助../
问候
How do i activate JS and other jquery functions, like masonry after the page is loaded.
i use:
jQuery("#filterbox").load("mypage.html"}); works fine, but eg. mansory is not activated.
jQuery('#content #boxes').masonry({ columnWidth: 122, animate: true });
but the second is not "activated".
is it correct that css, and js is not activated during .load, and if, how do i activate it afterward.
Thanks for any help..
/regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个:
顺便说一下,在
mypage.html
之后有一个额外的}
。Try this:
By the way, you have an extra
}
aftermypage.html
.由于 jQuery.load 是异步的,
jQuery('#content #boxes').masonry
将在调用 jQuery.load 后直接运行。您需要一种方法来告诉 jQuery 您想要在内容实际加载后执行该函数。jQuery.load 将回调函数作为第二个参数。此回调将在您的内容加载后执行。试试这个:
继续阅读.load() 文档。
Since jQuery.load is asynchronous,
jQuery('#content #boxes').masonry
will run DIRECTLY after the call to jQuery.load. You need a way to tell jQuery that you want to execute that function after the content actually has been loaded.jQuery.load takes a callback function as the second argument. This callback will execute after your content has loaded. Try this:
Go ahead and read the documentation for .load().
试试这个
Try this
添加 ImagesLoaded 脚本
https://github.com/desandro/imagesloaded/blob/master/imagesloaded.js尝试
:
它对我有用,希望这对您也有帮助
我的示例(在导航中选择图库):
http://test.crystalstudio.me/nms/
Add a ImagesLoaded script
https://github.com/desandro/imagesloaded/blob/master/imagesloaded.js
Try:
It works for me, hope this helps you too
my example (choose gallery in navigation):
http://test.crystalstudio.me/nms/