Jquery UI Slider Pips throws “No such method 'pips' for slider widget instance” in WordPress

白昼怎懂夜的黑 提交于 2021-01-29 03:40:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!