您好我正在尝试在Silverstripe中使用Infinite Ajax Scroll。
设置如“入门”页面中所述 http://infiniteajaxscroll.com/docs/getting-started.html和" jquery-ias.min.js"在我的Page.ss模板AFTER包括jquery.js
上引用了include语句但无论我如何尝试,我都会得到:TypeError: $ is undefined
知道我错过了什么吗? THX!
Page.ss
<% require javascript('framework/thirdparty/jquery/jquery.js') %>
<% require javascript('framework/thirdparty/jquery-tools/jquery.tools.min.js') %>
<% require javascript('framework/thirdparty/jquery-ias.min.js') %>
<script type="text/javascript" src="{$ThemeDir}/javascript/script.js"></script>
的script.js
jQuery.noConflict();
// jQuery.noConflict(); <-- uncommenting jQuery.noConflict solves it!
(function($) {
$( document ).ready(function() {
var ias = jQuery.ias({
container: '#posts',
item: '.post',
pagination: '#pagination',
next: '.next'
});
});
}(jQuery));
标记
<div id="posts">
<div class="post">...</div>
<div class="post">...</div>
</div>
<div id="pagination">
<a href="/page2/" class="next">next</a>
</div>
答案 0 :(得分:1)
解决方案是离开jQuery.noConflict();
!
// jQuery.noConflict(); <-- uncommenting jQuery.noConflict solves it!
(function($) {
$( document ).ready(function() {
var ias = jQuery.ias({
container: '#posts',
item: '.post',
pagination: '#pagination',
next: '.next'
});
});
}(jQuery));