Search code examples
javascriptjqueryslidercompatibilityuislider

Migrating from jQuery 1.9.1 to 1.10.1 causing error: Object has no method


  1. View my jsFiddle

  2. Resize HTML preview to small width and see that slideshow is resized properly

  3. Change jQuery from 1.9.1 to 1.10.1 (in left pane) and click RUN

  4. Resize HTML preview to a small or large width

  5. Open console, and see error: Object [object Object] has no method 'bjqs'

I cannot figure out what about the bjqs plugin is causing this problem with 1.10.1.

Is there something about the plugin preventing it from working the 2nd time it's called in the resize function?

JavaScript is included here, but jsFiddle linked above is going to be a better place to view it.

Plugin I am using is: http://www.basic-slider.com/

$(function () {

    $(window).resize(function () {
        if (this.resizeTO) clearTimeout(this.resizeTO);
        this.resizeTO = setTimeout(function () {
            slideShow(); // re-init on resize stop
        }, 500);
    });

    function slideShow() {
        $('.bjqs-controls, .bjqs-markers').remove();
        console.log($(window).width());

        var ss_width;
        var ss_height;

        if ($(window).width() >= 600) {
            // Desktop
            ss_width = 300;
            ss_height = 200;
        } else if ($(window).width() < 600) {
            // Tablet
            ss_width = 150;
            ss_height = 150;
        }

        // Load content slideshow
        $('#banner-slide').bjqs({
            nexttext: 'Next',
            prevtext: 'Prev',
            showmarkers: true,
            centermarkers: true, // horizontally center markers            
            responsive: false, // enable responsive behaviour
            width: ss_width,
            height: ss_height
        });
    }

    // Init slide show on load
    slideShow();

});

Solution

  • The root cause of the error within said plugin is /^\d\.\d+/i.exec(jQuery.fn.jquery))<1.6 it compares the string "1.10" to "1.6" using alphanumeric sorting, therefore "1.6" > "1.10", so it includes it's own version and doesn't properly prevent conflicts. I'd suggest reporting this as a bug to the plugin author, it should be trivial to fix.