Skip to content

Upgrade from 2.3.1 to 3.x no working #384

@vishy93

Description

@vishy93

Hey,

I am currently looking to use the Strategy Magento plugin, which includes this plugin for Infinite Scrolling.

However, it is using the old version 2.2.1. I have accordingly tried changing it to the new 3.x version.

But, I get the following error:

Uncaught TypeError: $.ias is not a function

The plugin is correctly included into the page, and this is the init:


   <?php?>
   <?php if($this->isEnabled()): ?>
    <?php
    $configData = $this->getConfigData();
    $helper = Mage::helper('infinitescroll');
    $productListMode = $this->getProductListMode();
    ?>
    <?php if(Mage::getStoreConfig('infinitescroll/general/jquery')): ?>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="<?php echo $this->getJsUrl('jquery/jquery.1.10.2.min.js') ?>"><\/script>')</script>
        <script>jQuery.noConflict();</script>
    <?php endif ?>
    <?php if($iasConfig = $helper->getConfigData('advanced/ias_config')) :?>
        <script src="<?php echo $this->getSkinUrl($iasConfig) ?>"></script>
    <?php endif ?>
    <script type="text/javascript">
        //<![CDATA[
        windowLoadedFlag = false;
        window.onload = function () {
            windowLoadedFlag = true;
        };
        <?php // use: jQueryWaiter.execute(function(){ // safe jQuery code here });  ?>
        var jQueryWaiter = function () {
            var functions = [];
            var timer = function() {
                if( typeof window.jQuery != 'undefined') {
                    while (functions.length) {
                        functions.shift()(window.jQuery);
                    }
                } else {
                    window.setTimeout(timer, 100);
                }
            };
            timer();
            return {
                execute: function(onJQueryReady) {
                    if (window.jQuery) {
                        onJQueryReady(window.jQuery);
                    } else {
                        functions.push(onJQueryReady);
                    }
                }
            };
        }();
        window.SgyIAS = {
            debug: <?php echo $helper->getConfigData('general/debug'); ?>,
            _log: function(object) {
                if(this.debug) {
                    console.log(object);
                }
            },
            init: function(){
                jQuery.getScript("<?php echo $this->getJsUrl('jquery/infinitescroll/jquery-ias.min.js') ?>", function() {
                    jQuery(function($) {
                        var config = {
                            item: '<?php echo $productListMode == 'grid' ? $helper->getConfigData('selectors/items_grid') : $helper->getConfigData('selectors/items_list') ?>',
                            container : '<?php echo $helper->getConfigData('selectors/content') ?>',
                            next: '<?php echo $helper->getConfigData('selectors/next') ?>',
                            pagination: '<?php echo $helper->getConfigData('selectors/pagination') ?>',
                            delay: 600,
                            negativeMargin: <?php echo (int) $helper->getConfigData('design/buffer_px') ?>,
                            history: {
                                prev: '<?php echo $helper->getConfigData('selectors/previous') ?>'
                            },
                            noneleft: {
                                text: '<?php echo $helper->jsQuoteEscape($this->__($helper->getConfigData('design/done_text'))) ?>',
                                html: '<div class="ias-noneleft" style="text-align: center;">{text}</div>'
                            },
                            spinner: {
                                <?php if($this->getLoaderImage() !== false): ?>
                                src: '<?php echo $this->getLoaderImage() ?>',
                                <?php else: ?>
                                src: 'data:image/gif;base64,R0lGODlhEAAQAPQAAP///wAAAPDw8IqKiuDg4EZGRnp6egAAAFhYWCQkJKysrL6+vhQUFJycnAQEBDY2NmhoaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAAFdyAgAgIJIeWoAkRCCMdBkKtIHIngyMKsErPBYbADpkSCwhDmQCBethRB6Vj4kFCkQPG4IlWDgrNRIwnO4UKBXDufzQvDMaoSDBgFb886MiQadgNABAokfCwzBA8LCg0Egl8jAggGAA1kBIA1BAYzlyILczULC2UhACH5BAkKAAAALAAAAAAQABAAAAV2ICACAmlAZTmOREEIyUEQjLKKxPHADhEvqxlgcGgkGI1DYSVAIAWMx+lwSKkICJ0QsHi9RgKBwnVTiRQQgwF4I4UFDQQEwi6/3YSGWRRmjhEETAJfIgMFCnAKM0KDV4EEEAQLiF18TAYNXDaSe3x6mjidN1s3IQAh+QQJCgAAACwAAAAAEAAQAAAFeCAgAgLZDGU5jgRECEUiCI+yioSDwDJyLKsXoHFQxBSHAoAAFBhqtMJg8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ZKv4NqNLKK2/Q4Ek4lFXChsg5ypJjs1II3gEDUSRInEGYAw6B6zM4JhrDAtEosVkLUtHA7RHaHAGJQEjsODcEg0FBAFVgkQJQ1pAwcDDw8KcFtSInwJAowCCA6RIwqZAgkPNgVpWndjdyohACH5BAkKAAAALAAAAAAQABAAAAV5ICACAimc5KieLEuUKvm2xAKLqDCfC2GaO9eL0LABWTiBYmA06W6kHgvCqEJiAIJiu3gcvgUsscHUERm+kaCxyxa+zRPk0SgJEgfIvbAdIAQLCAYlCj4DBw0IBQsMCjIqBAcPAooCBg9pKgsJLwUFOhCZKyQDA3YqIQAh+QQJCgAAACwAAAAAEAAQAAAFdSAgAgIpnOSonmxbqiThCrJKEHFbo8JxDDOZYFFb+A41E4H4OhkOipXwBElYITDAckFEOBgMQ3arkMkUBdxIUGZpEb7kaQBRlASPg0FQQHAbEEMGDSVEAA1QBhAED1E0NgwFAooCDWljaQIQCE5qMHcNhCkjIQAh+QQJCgAAACwAAAAAEAAQAAAFeSAgAgIpnOSoLgxxvqgKLEcCC65KEAByKK8cSpA4DAiHQ/DkKhGKh4ZCtCyZGo6F6iYYPAqFgYy02xkSaLEMV34tELyRYNEsCQyHlvWkGCzsPgMCEAY7Cg04Uk48LAsDhRA8MVQPEF0GAgqYYwSRlycNcWskCkApIyEAOwAAAAAAAAAAAA==',
                                <?php endif; ?>
                                html: '<div class="ias-spinner" style="text-align: center;"><img style="display:inline" src="{src}"/> <?php echo $helper->jsQuoteEscape($this->__($helper->getConfigData('design/loading_text'))); ?></div>'
                            },
                            trigger: {
                                text: '<?php echo $helper->jsQuoteEscape($this->__($helper->getConfigData('design/load_more_text'))) ?>',
                                html: '<div class="ias-trigger ias-trigger-next" style="text-align: center; cursor: pointer;"><a>{text}</a></div>',
                                textPrev: '<?php echo $helper->jsQuoteEscape($this->__($helper->getConfigData('design/load_more_text_prev'))) ?>',
                                htmlPrev: '<div class="ias-trigger ias-trigger-prev" style="text-align: center; cursor: pointer;"><a>{text}</a></div>',
                                offset: <?php echo (int) $helper->getConfigData('design/load_more_threshold') ?>
                            }
                        };
                        if (window.ias_config){
                            $.extend(config, window.ias_config);
                        }
                        SgyIAS._log({extension: 'ias', config: config});
                        window.ias = $.ias(config);
                        SgyIAS._log({extension: 'paging'});
                        window.ias.extension(new IASPagingExtension());
                        SgyIAS._log({extension: 'spinner'});
                        window.ias.extension(new IASSpinnerExtension(config.spinner));
                        SgyIAS._log({extension: 'noneleft'});
                        window.ias.extension(new IASNoneLeftExtension(config.noneleft));
                        SgyIAS._log({extension: 'trigger'});
                        window.ias.extension(new IASTriggerExtension(config.trigger));
                        <?php if($helper->isMemoryActive()): ?>
                        SgyIAS._log({extension: 'history'});
                        window.ias.extension(new IASHistoryExtension(config.history));
                        <?php endif; ?>
                        // debug events:
                        window.ias.on('scroll', function(scrollOffset, scrollThreshold){
                            SgyIAS._log({eventName: 'scroll', scrollOffset: scrollOffset, scrollThreshold: scrollThreshold});
                        });
                        window.ias.on('load', function(event){
                            SgyIAS._log({eventName:'load', event: event});
                        });
                        window.ias.on('loaded', function(data, items){
                            SgyIAS._log({eventName: 'loaded', data: data, items: items});
                        });
                        window.ias.on('render', function(items){
                            SgyIAS._log({eventName: 'render', items: items});
                        });
                        window.ias.on('rendered', function(items){
                            SgyIAS._log({eventName: 'render', items: items});
                            if (typeof $j !== 'undefined' && !!$j) {
                                $j(window).trigger('delayed-resize');
                            }
                        });
                        window.ias.on('noneLeft', function(){
                            SgyIAS._log({eventName: 'noneLeft'});
                        });
                        window.ias.on('next', function(url){
                            SgyIAS._log({eventName: 'next', url: url});
                        });
                        window.ias.on('ready', function(){
                            SgyIAS._log({eventName: 'ready'});
                        });
                        $('<?php echo Mage::getStoreConfig('infinitescroll/selectors/toolbar') ?>').<?php echo $helper->getConfigData('design/hide_toolbar') ? 'hide' : 'show' ?>();
                        // custom fix for url protocol issue in jquery ias library:
                        window.ias.getNextUrl = function(container) {
                            if (!container) {
                                container = window.ias.$container;
                            }
                            // always take the last matching item + fix to be protocol relative
                            var nexturl = $(window.ias.nextSelector, container).last().attr('href');
                            if(typeof nexturl !== "undefined") {
                                if (window.location.protocol == 'https:') {
                                    nexturl = nexturl.replace('http:', window.location.protocol);
                                } else {
                                    nexturl = nexturl.replace('https:', window.location.protocol);
                                }
                            }
                            return nexturl;
                        };
                        // custom fix for url protocol issue in jquery ias library.
                        if(windowLoadedFlag){
                            $(window).load();
                        }
                        SgyIAS._log('Done loading IAS.');
                        $(document).trigger( "infiniteScrollReady", [window.ias]);
                    });
                });
            }
        };
        <?php // this will prevent executing the infinite scroll before jQuery is loaded even when jQuery is loaded after this code ?>
        jQueryWaiter.execute(function(){
            SgyIAS.init();
        });
        //]]>
    </script>
<?php endif ?>
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions