c# - 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'cookie' -


i developing mvc web application. have added following scripts in bundle

 bundles.add(new scriptbundle("~/bundles/adminscripts").include(                     "~/scripts/jquery.js",                     "~/scripts/bootstrap.js",                     "~/scripts/jquery.dcjqaccordion.2.7.js",                     "~/scripts/jquery.scrollto.min.js",                     "~/scripts/jquery.nicescroll.js",                     "~/scripts/jquery.sparkline.js",                     "~/scripts/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.js",                     "~/scripts/owl.carousel.js",                     "~/scripts/jquery.customselect.js",                     "~/scripts/respond.js",                     "~/scripts/slidebars.js",                     "~/scripts/common-scripts.js",                     "~/scripts/sparkline-chart.js",                     "~/scripts/easy-pie-chart.js",                     "~/scripts/count.js",                     "~/scripts/main.js")); 

when run site giving me error

0x800a01b6 - javascript runtime error: object doesn't support property or method 'cookie'

instead of adding these scripts in bundle if add on _layout.cshtml works fine. have added bundletable.enableoptimizations = true; in bundle.config. not getting issue. can me solve this? searched cookie keyword entire solution , didn't find anything. please see following screenshot

enter image description here

i have upgraded scripts using nugget command line package manager. still problem isn't solved. found script cause issue.

edit

~/scripts/common-scripts.js script giving me error.

here script code

/*---left bar accordion----*/ $(function () {     $('#nav-accordion').dcaccordion({         eventtype: 'click',         autoclose: true,         savestate: true,         disablelink: true,         speed: 'slow',         showcount: false,         autoexpand: true,         //        cookie: 'dcjq-accordion-1',         classexpand: 'dcjq-current-parent'     }); });  // right slidebar $(function () {     $.slidebars(); });  var script = function () {      //    sidebar dropdown menu auto scrolling     jquery('#sidebar .sub-menu > a').click(function () {         var o = ($(this).offset());         diff = 250 - o.top;         if (diff > 0)             $("#sidebar").scrollto("-=" + math.abs(diff), 500);         else             $("#sidebar").scrollto("+=" + math.abs(diff), 500);     });      //    sidebar toggle     $(function () {         function responsiveview() {             var wsize = $(window).width();             if (wsize <= 768) {                 $('#container').addclass('sidebar-close');                 $('#sidebar > ul').hide();             }              if (wsize > 768) {                 $('#container').removeclass('sidebar-close');                 $('#sidebar > ul').show();             }         }         $(window).on('load', responsiveview);         $(window).on('resize', responsiveview);     });      $('.fa-bars').click(function () {         if ($('#sidebar > ul').is(":visible") === true) {             $('#main-content').css({                 'margin-left': '0px'             });             $('#sidebar').css({                 'margin-left': '-210px'             });             $('#sidebar > ul').hide();             $("#container").addclass("sidebar-closed");         } else {             $('#main-content').css({                 'margin-left': '210px'             });             $('#sidebar > ul').show();             $('#sidebar').css({                 'margin-left': '0'             });             $("#container").removeclass("sidebar-closed");         }     });      // custom scrollbar     $("#sidebar").nicescroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '' });      $("html").nicescroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '6', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '', zindex: '1000' });      // widget tools     jquery('.panel .tools .fa-chevron-down').click(function () {         var el = jquery(this).parents(".panel").children(".panel-body");         if (jquery(this).hasclass("fa-chevron-down")) {             jquery(this).removeclass("fa-chevron-down").addclass("fa-chevron-up");             el.slideup(200);         } else {             jquery(this).removeclass("fa-chevron-up").addclass("fa-chevron-down");             el.slidedown(200);         }     });      // default collapse widget     //    $('.panel .tools .fa').click(function () {     //        var el = $(this).parents(".panel").children(".panel-body");     //        if ($(this).hasclass("fa-chevron-down")) {     //            $(this).removeclass("fa-chevron-down").addclass("fa-chevron-up");     //            el.slideup(200);     //        } else {     //            $(this).removeclass("fa-chevron-up").addclass("fa-chevron-down");     //            el.slidedown(200); }     //    });      jquery('.panel .tools .fa-times').click(function () {         jquery(this).parents(".panel").parent().remove();     });      //    tool tips     $('.tooltips').tooltip();      //    popovers     $('.popovers').popover();      // custom bar chart     if ($(".custom-bar-chart")) {         $(".bar").each(function () {             var = $(this).find(".value").html();             $(this).find(".value").html("");             $(this).find(".value").animate({                 height:             }, 2000)         })     } }(); 

looking @ source of dcjqaccordian, tries call $.cookie save it's state. you'll need add jquery.cookie script work: https://github.com/carhartl/jquery-cookie or https://www.nuget.org/packages/jquery.cookie/

so, bundle like:

bundles.add(new scriptbundle("~/bundles/adminscripts").include(                     "~/scripts/jquery.js",                     "~/scripts/jquery.cookie.*",                     "~/scripts/bootstrap.js",                     "~/scripts/jquery.dcjqaccordion.2.7.js",                     ... etc. 

as aside, avoid using plain "jquery.js" reference; assuming you're using nuget package, use:

bundles.add(new scriptbundle("~/bundles/adminscripts").include(                     "~/scripts/jquery-{version}.js",                     "~/scripts/jquery.cookie.*",                     "~/scripts/bootstrap.js",                     "~/scripts/jquery.dcjqaccordion.2.7.js",                     ... etc. 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -