jQuery UI Slider doesn't always load correctly (with Modernizr) -


i'm having problems loading jquery ui slider. (only on production server, loads on local dev server)

the thing is, jquery ui slider doesn't render (no handles, , when click on slider says

uncaught typeerror: cannot call method 'addclass' of undefined 

modernizr.load starts here:

modernizr.load([     {         test: window.matchmedia,         nope: "{{ asset('bundles/projectmain/js/polyfills/respond.min.js') }}"     },     {         load: [             '//code.jquery.com/jquery-1.9.1.js',             '//code.jquery.com/ui/1.10.1/jquery-ui.js'         ],         complete: function () {             if ( !window.jquery ) {                 modernizr.load("{{ asset('bundles/projectmain/js/vendor/jquery-1.9.1.min.js') }}");             }         }     },     {         load: [             "iegt5!ielt9!{{ asset('bundles/projectmain/js/vendor/selectivizr-min.js') }}",             "{{ asset('bundles/projectmain/js/plugins.js') }}",             "{{ asset('bundles/projectmain/js/main.js') }}"         ]     } ]); 

main.js:

(function($) {     this.init = function() {        this.ageslider();     this.rankingslider();      this.equalheights($('.filter-grid > div'));     this.equalheights($('.members-grid > .item .user'));     this.equalheights($('.members-grid > .item .info'));      $('input, textarea').placeholder();      $('.page.landing').backstretch('/bundles/projectmain/img/bg.jpg');     $('.page.normal > header').backstretch('/bundles/projectmain/img/bg.jpg');      if( /android|webos|iphone|ipad|ipod|blackberry/i.test(navigator.useragent) )      {         // nothing please         } else         {             $('input[type="checkbox"]').ezmark();          } }();     })(jquery); 

age slider function in main.js

this.ageslider = function()  { var minvalue = parseint($('#project_user_search_minage').val()); var maxvalue = parseint($('#project_user_search_maxage').val());  $('.age .slider').slider( {     range: true,     min: '0', max: '100',     values: [minvalue, maxvalue],     create: function(e, ui)     {         $('.age .amount').html('between ' + minvalue + ' , ' + maxvalue);     },     slide: function(e, ui)      {     $('.age .amount').html('between ' + ui.values[0] + ' , ' + ui.values[1]);     $('#project_user_search_minage').val(ui.values[0]);     $('#project_user_search_maxage').val(ui.values[1]);     },     change: function(e, ui)     {         $('#search').submit();     } }); }; 

// edit: found out cause of problem. code in init function in main.js isn't executed on page load when main.js loaded (so earlier page load). use values coming html elements initialize sliders, sliders initialize if page loaded on time. try put $(document).ready around of code in main.js , see give me.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -