surveyjs / surveyjs-wordpress

Example of integration SurveyJS: Survey Library and Survey Creator into WordPress
https://wordpress.org/plugins/surveyjs/
38 stars 18 forks source link

How to implement range-slider in WordPress surveys? #16

Closed msbt closed 4 years ago

msbt commented 4 years ago

Hi there! I already posted here but it doesn't seem to get the traction that I need ;)

In short: As the title Suggests, how can I add custom widgets in WordPress? I need a range-slider urgently and don't know where to put/include the js files

<script src="https://unpkg.com/nouislider@9.2.0/distribute/nouislider.js"></script>
<script src="https://surveyjs.azureedge.net/1.5.17/surveyjs-widgets.js"></script>

Any pointers are appreciated!

Best regards

tsv2013 commented 4 years ago

The question is related to wordpress scripts initialization

Admin scripts and styles are loaded here - https://github.com/surveyjs/surveyjs-wordpress/blob/master/initializer.php#L86-L89

Client scripts and styles here - https://github.com/surveyjs/surveyjs-wordpress/blob/master/initializer.php#L108-L112

msbt commented 4 years ago

thanks for the quick reply @tsv2013! adding those 2 js files to both, admin and frontend should do the trick?

msbt commented 4 years ago

ok I've got it to work, for the record: those files are required for the nouislider:

        wp_enqueue_script('wps-survey-jquery3-js', plugins_url('libs/jquery.js', __FILE__) );
        wp_enqueue_script('wps-survey-nouislider-js', plugins_url('libs/nouislider.js', __FILE__) );
        wp_enqueue_script('wps-survey-widgets-js', plugins_url('libs/surveyjs-widgets.js', __FILE__) );
        wp_enqueue_style('wps-survey-nouislider-css', plugins_url('libs/nouislider.min.css', __FILE__) );