Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello All,

I use jquery for next and previous in popup. that popup contains some data. next and previous working perfectly on chrome and firefox but in ie its not working. i dont know the reason please review my code and give me any solution.

JavaScript
/*modal boxes****/

        $('.modal-box').hide();
        var meal = $('.meal');
        var currIndex = 0;
        var nextIndex = 0;
        var prevIndex = 0;
        var popClass = null;

        $('.bind').click(function (event) {
            var y = window.pageYOffset;
            event.preventDefault();
            $('.modal-box').hide();
            var meal = $('.meal');
            currIndex = meal.index(this);
            nextIndex = currIndex + 1;
            prevIndex = currIndex - 1;
            if (currIndex >= meal.length - 1) {
                nextIndex = 0;
            }
            else if (currIndex <= 0) {
                prevIndex = $(meal).length - 1;
            }
            $('.modal-box', this).modal({
                overlayClose: true
            });
            popClass = ('.simplemodal-container' + $(this).attr('id'));
            $(popClass).css("display", "block");
            $('.modal-box').css("display", "block");
            $('html, body').animate({ scrollTop: y });
            return false;
        });

       $('.next').click(function () {
            var y = window.pageYOffset;
            var mealLi = meal.eq(nextIndex);
            $.modal.close();
            $('.modal-box', mealLi).modal({
                overlayClose: true
            });
            currIndex = nextIndex;
            prevIndex = currIndex - 1;
            nextIndex = currIndex + 1;
            if (currIndex >= meal.length - 1) {
                nextIndex = 0;
            }
            $(this).val('');
            $('html, body').animate({ scrollTop: y });
        });

        $('.prev').click(function () {
            var y = window.pageYOffset;
            var mealLi = meal.eq(prevIndex);
            $.modal.close();
            $('.modal-box', mealLi).modal({
                overlayClose: true
            });
            currIndex = prevIndex;
            nextIndex = currIndex + 1;
            prevIndex = currIndex - 1;
            if (currIndex <= 0) {
                prevIndex = $(meal).length - 1;;
            }
            $(this).val('');
            $('html, body').animate({ scrollTop: y });
        });

        $('.simplemodal-close').click(function (e) {
            $('.modal-box', this).modal({
                overlayClose: false
            });
            $('#simplemodal-container').hide();
            $(popClass).css("display", "none");
            e.preventDefault();
            $('.modal-box').hide();
            popClass = null;
            return false;
        });
        /*modal boxes***/


Thanks & Regards
Sampath
Posted
Updated 4-Dec-13 1:45am
v3
Comments
Adam R Harris 4-Dec-13 15:42pm    
Check the javascript console (F12) and see what the error is, its probably an issue with a property not existing in IE but existing in FF and Chrome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900