1

Hi I am trying to use Infinite Ajax Scroll in Silverstripe.

The setup is as described in the Getting Started Page http://infiniteajaxscroll.com/docs/getting-started.html and the "jquery-ias.min.js" is referenced with an include statement on my Page.ss Template AFTER including jquery.js

But regardless how I am trying, I get: TypeError: $ is undefined

Any idea what I am missing out? 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));

Markup

<div id="posts">
    <div class="post">...</div>
    <div class="post">...</div>
</div>

<div id="pagination">
    <a href="/page2/" class="next">next</a>
</div>
5
  • 1
    Do you actually need the noconflict? That error simply means no jQuery loaded
    – Martijn
    Jun 16, 2014 at 8:53
  • @Martijn you're right! noconflict solves the problem! THX
    – rfLo
    Jun 16, 2014 at 9:40
  • On what line of code do you get the TypeError?
    – Fieg
    Jun 18, 2014 at 9:03
  • taking out jQuery.noConflict() is the solution
    – rfLo
    Jun 20, 2014 at 15:48
  • 1
    glad you solved it, could you please post an answer and accept it to mark this question as resolved? Jun 23, 2014 at 12:33

1 Answer 1

1

The solution is to leave jQuery.noConflict(); away!

// jQuery.noConflict(); <-- uncommenting jQuery.noConflict solves it!

(function($) {
    $( document ).ready(function() {

        var ias = jQuery.ias({
          container:  '#posts',
          item:       '.post',
          pagination: '#pagination',
          next:       '.next'
        });
     });
}(jQuery));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.