问题
I am working on a review option for a webshop in WooCommerce for one of my clients. Now I want to use the jQuery UI Slider Pips extension.
All works fine on a testpage on my own server. And all works fine in this fiddle as well.
But I got an "Uncaught Error: no such method 'pips' for slider widget instance"-error in my WP installation.
I have tried to overrule the default WP jQuery version with the one from the fiddle, but nothing seems to work.
Here the page that I am testing on.
Can you help me please !
My (Rendered) HTML
<select name="rating" id="rating">
<option value="">Geen Mening</option>
<option value="1">Zeer slecht</option>
<option value="2">Niet slecht</option>
<option value="3">Gemiddeld</option>
<option value="4">Goed</option>
<option value="5">Perfect</option>
</select>
My JS
var optionsdropdown = $( "#rating" );
var doubleLabels = new Array();
optionsdropdown.find('option').each(function() {
//alert($j(this).val()+' :: '+$j(this).text());
doubleLabels.push( '<i>' + $(this).val() + '</i><span>' + $(this).text() + '</span>' );
});
var slider = $( "<div id='double-label-slider'></div>" ).insertAfter( optionsdropdown );
$("#double-label-slider")
.slider({
min: 0,
max: $('#rating > option').length - 1,
animate: 400,
slide: function( event, ui ) {
optionsdropdown[ 0 ].selectedIndex = ui.value;
}
})
.slider('pips', {
rest: 'label',
labels: doubleLabels
});
回答1:
This solution is for Rails. But I hope this helps you.
You have to insert following line to application.js
//=jquery-ui-slider-pips.min
I've found this answer after 5 hours of brainstorming.
来源:https://stackoverflow.com/questions/37319159/jquery-ui-slider-pips-throws-no-such-method-pips-for-slider-widget-instance