Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery UI Slider doesn't always load correctly (with Modernizr)
    primarykey
    data
    text
    <p>I'm having some problems with loading a jQuery UI slider. (only on production server, as it always loads perfectly on my local dev server)</p> <p>The thing is, the jQuery UI Slider doesn't render properly (no handles, and when I click on the slider it says </p> <pre><code>Uncaught TypeError: Cannot call method 'addClass' of undefined </code></pre> <p>Modernizr.load starts here:</p> <pre><code>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') }}" ] } ]); </code></pre> <p>Main.js:</p> <pre><code>(function($) { this.init = function() { this.ageSlider(); this.rankingSlider(); this.equalHeights($('.filter-grid &gt; div')); this.equalHeights($('.members-grid &gt; .item .user')); this.equalHeights($('.members-grid &gt; .item .info')); $('input, textarea').placeholder(); $('.page.landing').backstretch('/bundles/projectmain/img/bg.jpg'); $('.page.normal &gt; header').backstretch('/bundles/projectmain/img/bg.jpg'); if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { // do nothing please } else { $('input[type="checkbox"]').ezMark(); } }(); })(jQuery); </code></pre> <p>age slider function in main.js</p> <pre><code>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 + ' and ' + maxValue); }, slide: function(e, ui) { $('.age .amount').html('Between ' + ui.values[0] + ' and ' + 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(); } }); }; </code></pre> <p>// Edit: I found out the cause of the problem. The code in the init function in Main.js isn't executed on page load but when Main.js is fully loaded (so earlier than page load). As I use values coming from HTML elements to initialize the sliders, the sliders will only initialize successfully if the page is loaded on time. So now I will try to put a $(document).ready around all of the code in Main.js and see what that will give me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload