嗨,我试图使用无限Ajax滚动在Silverstripe。
设置如入门页中所述http://infiniteajaxscroll.com/docs/getting-started.html和"jquery- as.min.js"在我的页面上引用了一个包含语句。jquery.js
但无论我如何尝试,我得到:TypeError: $ is undefined
你知道我错过了什么吗?谢谢!
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>
解决方案是离开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));